Skip to content

Commit

Permalink
gba: s3m2gbt: Support empty patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioND committed May 20, 2022
1 parent d613c3a commit f66e8c4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gba/s3m2gbt/s3m2gbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ def __init__(self, header, channel, note, instrument, volume,
class S3MFilePattern(S3MFormatReader):

def __init__(self, data, offset):

# Check if we have asked to generate an empty pattern
if data == None:
cell = S3MFilePatternCell(0, 0, 0, 0, 0, 0, 0)
self.cells = []
for i in range(0, 64):
self.cells.append(cell)
return

self.data = data
self.read_ptr = offset

Expand Down Expand Up @@ -241,7 +250,8 @@ def __init__(self, data):
if offset != 0:
self.patterns[i] = S3MFilePattern(self.data, offset)
else:
raise S3MFormatError(f"Empty pattern: {i}")
# A NULL pointer means that the pattern is empty
self.patterns[i] = S3MFilePattern(None, 0)

# The file data is no longer needed

Expand Down

0 comments on commit f66e8c4

Please sign in to comment.