-
Notifications
You must be signed in to change notification settings - Fork 0
/
testrom.py
executable file
·72 lines (61 loc) · 3.78 KB
/
testrom.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
import base64
from edlinkn8 import Everdrive, NesRom, BPSPatch
# Test rom from: https://github.com/zohassadar/NESHelloWorld/tree/v0.1
TEST_ROM_LEN = 40976
FIFO_TESTROM = (
b"LQqpN5I=zsKY@UmPDN810s#Y}fGvR9fYyKlf$x9=ff9jEfmVTDfdB#pqzR=87<m$a3aY&TfQ10P0f2=8"
b"Yybd{$_;_gOr-@W0`LjO3lIgl$AE<kr3EPg@D1h*r3=~0fY1b~0EG*s3-BhT3mAFLfU2bhDG2Zg_7}Am"
b"DG!wwr3EPj@CeqM8i0vRpn#K|r3uCg5Cyr=fQ1T^l9>(W3Z)9!)0fM+3LuYxr3EQ~@CG0ifK0rP)J1?m"
b"@CT&{@B<*;fT;k52c-w_{7fu>00;&F2?qcG2mt~E0s{o80?-Dj0nh@e0EG$W43Fb|fQ1UF1BD1+r4aBB"
b"pa7*0kqzb#$ixuP_2vv<pa8KAnI-_pz!1>(<_ut^6wm~v74S3W45=%P@IXobjqpIJBA*n3g{2gaj)4`A"
b"iRBZd6{ZyM295AQ%Fz0V!2i(oVCD?1@j!(UkGPTWK!p-ulV5<L7KInB@j%Hz(2rn%VS?rs(DLRNOlE;#"
b"7#bWNA|xOg8yz1bB_R$C4-gd;6QBUTdV#e73JMAezJY-i0KSNUl>o@V2hiwXNQy|9Nag~m0fh&p2q4{o"
b"sQ`@yAdLkesfdjLAgK<G0U#jaglMQ}s%Sv&fjWXWgARnH2nwpb)q#Zoz1D$~X@k|NAdLnfsiBPqAfj)e"
b"gdjPDsUeL9Ad@DBg`$6#m4PCop@Ec>g1My(AWDR$3cXo`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P64UxKS_"
b"f}J=F3<eAgH~^o5kpKWPeoT`Ela~&YojgLBp{1EZJfDyQw|}~sKwxlqa9}{A47-g0e?A<Ocdws*uXlre"
b"y@CI`48H%bzfXdH{sX&52Es?=L)0lqfPZ="
)
def count_bytes(everdrive: Everdrive):
counter = 0
while True:
byte_ = everdrive.receive_data(1)
if not byte_:
break
counter += 1
print(counter)
def send_fifo(everdrive: Everdrive, *numbers):
payload = bytearray(n & 0xFF for n in numbers)
everdrive.write_fifo(payload)
def get_test_rom() -> bytearray:
rom = bytearray(TEST_ROM_LEN)
patch = base64.b85decode(FIFO_TESTROM)
bps_patch = BPSPatch(patch)
return bps_patch.patch_rom(rom)
if __name__ == "__main__":
everdrive = Everdrive()
testrom = NesRom(rom=get_test_rom(), name="testrom.nes")
everdrive.load_game(testrom)