Skip to content

Commit

Permalink
music: dump nibble
Browse files Browse the repository at this point in the history
  • Loading branch information
nstbayless committed May 4, 2023
1 parent 1c08ea1 commit 960ee5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def emucredits():
# note: not actually proper opcodes
note_opcode = {"name": "-", "doc": "Plays the given note with the given duration (in hex). '_' is a tie. '*' represents a portamento. Duration must be one of [1, 2, 3, 4, 6, 8, 10, 20], and the note must be _, *, or in the range 0-C inclusive"}

# dn: dump nibble
dn_opcode = {"name": "dn", "doc": "Dump nibble"}

music_opcodes = [
# note: opcodes 0-7 inclusive are actually interpreted as WAIT codes, but will execute
# if the wait-postfix code is 0xF.
Expand Down
8 changes: 5 additions & 3 deletions src/mmdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,9 @@ def get_duration_idx(self, music):

def get_nibbles(self, music, address):
nibbles = []
if self.op == constants.note_opcode["name"]:
if self.op == "dn":
return [int(self.args[0], 16)]
elif self.op == constants.note_opcode["name"]:
nibbles.append(self.get_duration_idx(music))
# duration
type = self.args[0]
Expand Down Expand Up @@ -1105,7 +1107,7 @@ def get_nibbles(self, music, address):
return nibbles

# opcode not found
assert(False)
assert False, f"Not found: {self.op}"
return []

class Music:
Expand Down Expand Up @@ -2630,7 +2632,7 @@ def stat(self, fname=None, oall=False):
out("# ")
out("# The following opcode are recognized:")
out("# ")
for opcode in [constants.note_opcode] + constants.music_opcodes:
for opcode in [constants.note_opcode] + constants.music_opcodes + [constants.dn_opcode]:
out("# " + opcode["name"])
out("# " + opcode["doc"])
out("#")
Expand Down

0 comments on commit 960ee5b

Please sign in to comment.