FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PSFTracker/player.py at master · PeterFidelman/PSFTracker · GitHub
PeterFidelman
PSFTracker
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
PSFTracker
/
player.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (53 loc) · 1.74 KB
Breadcrumbs
PSFTracker
/
player.py
Copy path
File metadata and controls
63 lines (53 loc) · 1.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# constants
kNumLinesInPattern
=
32
kNumBytesInLine
=
4
oNumChannels
=
0x02
# offset of field containing number of channels
oStartOfInstruments
=
0x23
# offset of field containing offset of first instrument
oStartOfSpFx
=
0x25
# offset of field containing offset of first spfx
oStartOfOrders
=
0x27
# offset of field containing offset of first order
oStartOfPatterns
=
0x29
# offset of field containing offset of first pattern
# variables updated at song load
aSong
=
0
# address at which song is loaded - not used in this demonstrator
numChannels
=
0
# variables updated at play time
state
=
0
# play/stop
order
=
0
pos
=
0
# load song
fh
=
open
(
'format'
,
'rb'
)
f
=
bytearray
(
fh
.
read
())
def
main
():
init_reset
()
while
True
:
play_a_line
()
# let user hit key before continuing
dummy
=
raw_input
()
# init/reset song
def
init_reset
():
global
numChannels
,
state
,
order
,
pos
pos
=
0
numChannels
=
f
[
aSong
+
oNumChannels
]
order
=
f
[
aSong
+
oStartOfOrders
]
if
order
==
f
[
aSong
+
oStartOfPatterns
]
+
aSong
:
print
"the song is zero length"
print
hex
(
numChannels
)
def
play_a_line
():
global
numChannels
,
state
,
order
,
pos
print
"pos %d:"
%
pos
for
channel
in
range
(
0
,
numChannels
):
pattern_num
=
f
[
order
+
channel
]
pattern
=
f
[
aSong
+
oStartOfPatterns
]
+
pattern_num
*
kNumLinesInPattern
*
kNumBytesInLine
line
=
f
[
pattern
+
(
pos
*
kNumBytesInLine
)]
print
"chan"
,
hex
(
channel
),
"ptn"
,
hex
(
pattern_num
),
"line"
,
hex
(
line
)
# move on to next line
pos
+=
1
print
# move on to next order if we're at the end of this one
if
pos
==
kNumLinesInPattern
:
pos
=
0
order
+=
numChannels
# loop to start of song if we're out of orders
if
order
==
f
[
aSong
+
oStartOfPatterns
]
+
aSong
:
order
=
f
[
aSong
+
oStartOfOrders
]
+
aSong
# call main
main
()
Back
|
FazBrowse Home
|
New Git URL