Skip to content

Commit

Permalink
Fixed Cartridge Finally
Browse files Browse the repository at this point in the history
  • Loading branch information
connornishijima committed Nov 26, 2022
1 parent e96c053 commit 5ff7218
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
Binary file added converter/05 African Mines.vgz
Binary file not shown.
3 changes: 2 additions & 1 deletion converter/CONVERT_VGZ_TO_ARDUINO.bat
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
"c:\Python27\python.exe" vgm_to_arduino.py %1
python.exe ./vgm_to_arduino.py %1
pause
65 changes: 36 additions & 29 deletions converter/vgm_to_arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,43 @@
import sys

dropped_file = sys.argv[1]
print dropped_file
print(dropped_file)

try:
with gzip.open(dropped_file, mode='r', compresslevel=9) as f:
data = f.read()
with gzip.open(dropped_file, mode='rb', compresslevel=9) as f:
data = f.read()

out_array = "";

iter = 0
for i in range(len(data)):
hex_item = hex(ord(data[i]))
if len(hex_item) < 4:
hex_item = hex_item[0]+hex_item[1]+"0"+hex_item[2]

out_array += hex_item
out_array += ", "

iter+=1
if iter == 150:
iter = 0
out_array += "\n "

out_array = out_array[:-2]
out_array = out_array.upper()
out_array = out_array.replace('X','x')

out_array = "uint8_t music[] = {\n " + out_array + "\n};"

with open("vgm_arduino.txt.","w+") as f:
f.write(out_array)
out_array = "";

iter = 0
for i in range(len(data)):
hex_item = hex(data[i])
if len(hex_item) < 4:
hex_item = hex_item[0]+hex_item[1]+"0"+hex_item[2]

out_array += hex_item
out_array += ", "

iter+=1
if iter == 150:
iter = 0
out_array += "\n "

out_array = out_array[:-2]
out_array = out_array.upper()
out_array = out_array.replace('X','x')

out_array = "uint8_t music[] = {\n " + out_array + "\n};"

print(out_array)

with open("vgm_arduino.txt.","w+") as f:
f.write(out_array)

print("\n------------------------------------------------------");
print( "Conversion complete, output stored in vgm_arduino.txt!")
print( "------------------------------------------------------");

except:
traceback.print_exc()
time.sleep(10)
traceback.print_exc()
time.sleep(10)
12 changes: 4 additions & 8 deletions src/Cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@ void Cartridge::frame_counter_cb(void (*action)()){
}

void Cartridge::init(){
sigmaDeltaSetup(p1_channel, 88200);
sigmaDeltaAttachPin(p1_pin, p1_channel);
sigmaDeltaSetup(p1_pin, p1_channel, 88200);
sigmaDeltaWrite(p1_channel, 0);

sigmaDeltaSetup(p2_channel, 88200);
sigmaDeltaAttachPin(p2_pin, p2_channel);
sigmaDeltaSetup(p2_pin, p2_channel, 88200);
sigmaDeltaWrite(p2_channel, 0);

sigmaDeltaSetup(n_channel, 88200);
sigmaDeltaAttachPin(n_pin, n_channel);
sigmaDeltaSetup(n_pin, n_channel, 88200);
sigmaDeltaWrite(n_channel, 0);

sigmaDeltaSetup(t_channel, 88200);
sigmaDeltaAttachPin(t_pin, t_channel);
sigmaDeltaSetup(t_pin, t_channel, 88200);
sigmaDeltaWrite(t_channel, 0);
}

Expand Down

0 comments on commit 5ff7218

Please sign in to comment.