forked from gardners/c65gs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makerom
executable file
·39 lines (32 loc) · 826 Bytes
/
makerom
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
#!/usr/bin/env python
from os.path import realpath, dirname, join
from sys import argv, path
# Read a binary file and use it to make an initialised RAM
w=open(argv[3]+".vhdl","w")
# Read in the ROM file
romdata=""
bytes_read = open(argv[2], "rb").read()
first=True
c=0;
count=0
for b in bytes_read:
if first:
first=False
else:
romdata=romdata+","
if c==8:
c=0;
#if c==0:
# romdata=romdata+"\n -- "+hex(count+0xe000)+"\n "
romdata=romdata+"x\""+b.encode('hex').upper()+"\""
count=count+1
c=c+1;
# Read ROM template file
lines=open(argv[1]).readlines()
for line in lines:
if line.find("THEROM")>-1:
line=line.replace("THEROM",argv[3])
if line.find("ROMDATA")>-1:
line=line.replace("ROMDATA",romdata)
w.write(line)
w.close()