forked from MSXALL/pymsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzex.py
executable file
·76 lines (51 loc) · 1.23 KB
/
zex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /usr/bin/python3
# (C) 2020 by Folkert van Heusden <[email protected]>
# released under AGPL v3.0
import sys
import time
from inspect import getframeinfo, stack
from z80 import z80
from screen_kb_dummy import screen_kb_dummy
io = [ 0 ] * 256
ram = [ 0 ] * 65536
def read_mem(a):
return ram[a]
def write_mem(a, v):
ram[a] = v
def read_io(a):
return io[a]
def write_io(a, v):
io[a] = v
def debug(x):
pass
dk = screen_kb_dummy(io)
dk.start()
cpu = z80(read_mem, write_mem, read_io, write_io, debug, dk)
fh = open('zexall.com', 'rb')
zex = [ int(b) for b in fh.read() ]
fh.close()
p = 0x0100
for b in zex:
write_mem(p, b)
p += 1
cpu.sp = 0xf000
cpu.pc = 0x0100
while True:
if cpu.pc == 0x0005:
if cpu.c == 2:
print('%c' % cpu.e, end='', flush=True)
elif cpu.c == 9:
a = cpu.m16(cpu.d, cpu.e)
str_ = ''
while True:
c = cpu.read_mem(a)
if c == ord('$'):
break
print('%c' % c, end='', flush=True)
str_ += chr(c)
a += 1
if 'Tests complete' in str_:
break
cpu._ret(True, 'bla')
continue
cpu.step()