makeall.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import os
  2. import sys
  3. import time
  4. import math
  5. import array
  6. import Image
  7. import math
  8. import pickle
  9. import zlib
  10. import gameduino2 as gd2
  11. packlist = {
  12. "Chip-8 Demos/Maze [David Winter, 199x]" : "Demo. Random maze made from 4x4 bitmaps",
  13. "Chip-8 Demos/Particle Demo [zeroZshadow, 2008]" : "Demo. Some particles",
  14. "Chip-8 Demos/Sierpinski [Sergey Naydenov, 2010]" : "Demo. Renders the Sierpinski gasket",
  15. "Chip-8 Demos/Stars [Sergey Naydenov, 2010]" : "Demo. Twinking stars",
  16. "Chip-8 Demos/Trip8 Demo (2008) [Revival Studios]" : "Demo: intro, 3D vectorballs, and 4 randomized dot-effects",
  17. "Chip-8 Demos/Zero Demo [zeroZshadow, 2007]" : "Demo. Four bouncing sprites ",
  18. "Chip-8 Games/Addition Problems [Paul C. Moews]" : "Addition fun. Enter the three digit sum",
  19. "Chip-8 Games/Astro Dodge [Revival Studios, 2008]" : "Dodge the asteroids. 5 starts. 2,4,6,8 move",
  20. "Chip-8 Games/Blinky [Hans Christian Egeberg, 1991]" : "Pacman",
  21. "Chip-8 Games/Bowling [Gooitzen van der Wal]" : "Bowling. Controls are complicated",
  22. "Chip-8 Games/Breakout [Carmelo Cortez, 1979]" : "You have six walls and 20 balls. 4 and 6 move the paddle",
  23. "Chip-8 Games/Brix [Andreas Gustafsson, 1990]" : "4 and 6 move the paddle",
  24. "Chip-8 Games/Cave" : "F starts. 2,4,6,8 guide the explorer",
  25. "Chip-8 Games/Coin Flipping [Carmelo Cortez, 1978]" : "Coin flipping simulator",
  26. "Chip-8 Games/Connect 4 [David Winter]" : "Two player game. 4,6 move, 5 to drop coin",
  27. "Chip-8 Games/Deflection [John Fort]" : "it's complicated",
  28. "Chip-8 Games/Figures" : "4,6 move the descending number",
  29. "Chip-8 Games/Filter" : "Catch the ball. 4,6 move",
  30. "Chip-8 Games/Guess [David Winter]" : "Think of a number 1-63. Press 5 if you see it, 2 if not",
  31. "Chip-8 Games/Hidden [David Winter, 1996]" : "Find pairs. 2,4,6,8 move, 5 reveals",
  32. "Chip-8 Games/Hi-Lo [Jef Winsor, 1978]" : "10 guesses to find a random number between 00 and 99",
  33. "Chip-8 Games/Kaleidoscope [Joseph Weisbecker, 1978]" : "2,4,6,8 create a pattern, 0 repeats. Try 44444442220",
  34. "Chip-8 Games/Landing" : "Clear your landing path. 8 drops a bomb",
  35. "Chip-8 Games/Lunar Lander (Udo Pernisz, 1979)" : "Lunar landing game",
  36. "Chip-8 Games/Merlin [David Winter]" : "Memory game. Repeat the sequence using keys 4,5,7,8",
  37. "Chip-8 Games/Missile [David Winter]" : "8 to shoot",
  38. "Chip-8 Games/Nim [Carmelo Cortez, 1978]" : "F to go first, B to go second. 1,2,3 removes counters",
  39. "Chip-8 Games/Paddles" : "4,6 control top paddle. 7,9 bottom paddle",
  40. "Chip-8 Games/Pong (1 player)" : "1,4 move",
  41. "Chip-8 Games/Pong 2 (Pong hack) [David Winter, 1997]" : "left player: 1,4 right player C,D",
  42. "Chip-8 Games/Pong [Paul Vervalin, 1990]" : "left player: 1,4 right player C,D",
  43. "Chip-8 Games/Puzzle" : "After the shuffle, put tiles back in order with 2,4,6,8",
  44. "Chip-8 Games/Sequence Shoot [Joyce Weisbecker]" : "Memory game. Remember the blink sequence, then repeat with C,D,E,F",
  45. "Chip-8 Games/Shooting Stars [Philip Baltzer, 1978]" : "Dodge stars, 2,4,6,8 move",
  46. "Chip-8 Games/Space Invaders [David Winter]" : "5 to start, 4,6 move and 5 shoots",
  47. "Chip-8 Games/Tank" : "shoot the target 2,4,6,8 and 5 shoots",
  48. "Chip-8 Games/Tetris [Fran Dachille, 1991]" : "4 rotates, 5,6 move, 7 drops",
  49. "Chip-8 Games/Tic-Tac-Toe [David Winter]" : "Two player game. 1-9 move",
  50. "Chip-8 Games/Vertical Brix [Paul Robson, 1996]" : "7 starts, 1,4 move the paddle",
  51. "Chip-8 Games/Wall [David Winter]" : "1,4 move",
  52. }
  53. class Chip8(gd2.prep.AssetBin):
  54. header = "../converted-assets/chip8_assets.h"
  55. def addall(self):
  56. font512 = "".join([chr(c) for c in [
  57. 0xF0, 0x90, 0x90, 0x90, 0xF0, # 0
  58. 0x20, 0x60, 0x20, 0x20, 0x70, # 1
  59. 0xF0, 0x10, 0xF0, 0x80, 0xF0, # 2
  60. 0xF0, 0x10, 0xF0, 0x10, 0xF0, # 3
  61. 0x90, 0x90, 0xF0, 0x10, 0x10, # 4
  62. 0xF0, 0x80, 0xF0, 0x10, 0xF0, # 5
  63. 0xF0, 0x80, 0xF0, 0x90, 0xF0, # 6
  64. 0xF0, 0x10, 0x20, 0x40, 0x40, # 7
  65. 0xF0, 0x90, 0xF0, 0x90, 0xF0, # 8
  66. 0xF0, 0x90, 0xF0, 0x10, 0xF0, # 9
  67. 0xF0, 0x90, 0xF0, 0x90, 0x90, # A
  68. 0xE0, 0x90, 0xE0, 0x90, 0xE0, # B
  69. 0xF0, 0x80, 0x80, 0x80, 0xF0, # C
  70. 0xE0, 0x90, 0x90, 0x90, 0xE0, # D
  71. 0xF0, 0x80, 0xF0, 0x80, 0xF0, # E
  72. 0xF0, 0x80, 0xF0, 0x80, 0x80, # F
  73. ]]).ljust(512, chr(0));
  74. names = "15PUZZLE BLINKY BLITZ BRIX CONNECT4 GUESS HIDDEN INVADERS KALEID MAZE MERLIN MISSILE PONG PONG2 PUZZLE SYZYGY TANK TETRIS TICTAC UFO VBRIX VERS WIPEOFF"
  75. for p,desc in sorted(packlist.items()):
  76. # Each game image is:
  77. # 000-1ff font
  78. # 200-ebf game code
  79. # ea0-ecf game title
  80. # ed0-fff game abstract
  81. code = font512 + open(p + ".ch8").read()
  82. code = code.ljust(0xf00, chr(0))
  83. title = p.split('/')[1]
  84. assert len(title) < 48
  85. if os.access(p + ".txt", os.R_OK):
  86. print "--------------------"
  87. print title
  88. print open(p + ".txt").read()
  89. code += title.ljust(48, chr(0))
  90. code += desc.ljust(208, chr(0))
  91. self.add(None, code)
  92. self.define("NGAMES", len(packlist));
  93. if __name__ == '__main__':
  94. mm = Chip8()
  95. mm.make()