@@ -91,6 +91,8 @@ def __init__(
91
91
self .sp = STACK_POINTER_START
92
92
self .index = 0
93
93
self .rpl = [0 ] * NUM_REGISTERS
94
+ self .pitch = 64
95
+ self .playback_rate = 4000
94
96
95
97
self .shift_quirks = shift_quirks
96
98
self .index_quirks = index_quirks
@@ -150,6 +152,7 @@ def __init__(
150
152
0x29 : self .load_index_with_reg_sprite , # Fs29 - LOAD I, Vs
151
153
0x30 : self .load_index_with_extended_reg_sprite , # Fs30 - LOAD I, Vs
152
154
0x33 : self .store_bcd_in_memory , # Fs33 - BCD
155
+ 0x3A : self .load_pitch , # Fx3A - PITCH Vx
153
156
0x55 : self .store_regs_in_memory , # Fs55 - STOR [I], Vs
154
157
0x65 : self .read_regs_from_memory , # Fs65 - LOAD Vs, [I]
155
158
0x75 : self .store_regs_in_rpl , # Fs75 - SRPL Vs
@@ -923,6 +926,21 @@ def store_bcd_in_memory(self):
923
926
self .memory [self .index + 2 ] = int (bcd_value [2 ])
924
927
self .last_op = f"BCD V{ x :01X} ({ bcd_value } )"
925
928
929
+ def load_pitch (self ):
930
+ """
931
+ Fx3A - PITCH Vx
932
+
933
+ Loads the value from register x into the pitch register. The
934
+ register calculation is as follows:
935
+
936
+ Bits: 15-12 11-8 7-4 3-0
937
+ F x 3 A
938
+ """
939
+ x = (self .operand & 0x0F00 ) >> 8
940
+ self .pitch = self .v [x ]
941
+ self .playback_rate = 4000 * 2 ** ((self .pitch - 64 ) / 48 )
942
+ self .last_op = f"PITCH V{ x :01X} "
943
+
926
944
def store_regs_in_memory (self ):
927
945
"""
928
946
Fn55 - STOR [I]
@@ -1011,6 +1029,8 @@ def reset(self):
1011
1029
self .sp = STACK_POINTER_START
1012
1030
self .index = 0
1013
1031
self .rpl = [0 ] * NUM_REGISTERS
1032
+ self .pitch = 64
1033
+ self .playback_rate = 4000
1014
1034
1015
1035
def load_rom (self , filename , offset = PROGRAM_COUNTER_START ):
1016
1036
"""
0 commit comments