Advertisement
Guest User

DCPU-16

a guest
Jul 5th, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import pygame, sys, time
  2. from random import randint
  3. from pygame.locals import *
  4. A = open('','rb')
  5. Memory = [0] * 0x10000
  6. PC = 0
  7. Vi = [0] * 8
  8. Stack = []
  9. EX = 0
  10. IA = 0
  11. i = 0
  12. c = 0
  13. d
  14. for b in A.read():
  15.     if (c == 0):
  16.         d = b << 8
  17.         c += 1
  18.     if (c == 1):
  19.         Memory[i] = d & b
  20.         c = 0
  21.         i += 1
  22.  
  23. def emulateCPU():
  24.     global Memory, PC, Stack, Vi, EX, IA
  25.     a = (Memory[PC] & FC00) >> 10
  26.     if (Memory[PC] & 0x1F) == 0:
  27.         opcode = Memory[PC] & 0x3FF
  28.         SpecialOpcode = True
  29.     else:
  30.         opcode = Memory[PC] & 1F
  31.         SpecialOpcode = False
  32.         b = (Memory[PC] & 3E0) >> 5
  33.     if opcode == 0x01 and not SpecialOpcode:
  34.         if b <= 0x07:
  35.             Vi[b] = a
  36.         if b <= 0x0f:
  37.             Memory[Vi[b & 0x07]] = a
  38.         if b <= 0x17:
  39.             Memory[(Vi[b & 0x07] + Memory[PC+1]) & 0xFFFF] = a
  40.         if b ==
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement