[pypy-svn] r52571 - pypy/branch/gameboy-emulator/pypy/lang/gameboy

cami at codespeak.net cami at codespeak.net
Sun Mar 16 01:33:12 CET 2008


Author: cami
Date: Sun Mar 16 01:33:11 2008
New Revision: 52571

Modified:
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboy.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/sound.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/video.py
Log:
fixed a small bug in gameboy.py. dropped some empty lines in sound.py and video.py.


Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboy.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboy.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboy.py	Sun Mar 16 01:33:11 2008
@@ -97,7 +97,7 @@
         self.getreceiver(address).write(address, data)
 
     def read(self, address):
-        self.getreceiver().read(address)
+        self.getreceiver(address).read(address)
 
     def getreceiver(self, address):
         if 0x0000 <= address <= 0x7FFF:

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/sound.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/sound.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/sound.py	Sun Mar 16 01:33:11 2008
@@ -256,16 +256,12 @@
 	def updateAudio(self):
 		if ((self.nr52 & 0x80) == 0):
 			return
-		
 		if ((self.nr52 & 0x01) != 0):
 			self.updateAudio1();
-
 		if ((self.nr52 & 0x02) != 0):
 			self.updateAudio2();
-
 		if ((self.nr52 & 0x04) != 0):
 			self.updateAudio3();
-
 		if ((self.nr52 & 0x08) != 0):
 			self.updateAudio4();
 
@@ -273,19 +269,14 @@
 	def mixAudio(self,buffer, length):
 		for index in range(0, length):
 			buffer[index] = 0;
-
 		if ((self.nr52 & 0x80) == 0):
 			return
-		
 		if ((self.nr52 & 0x01) != 0):
 			self.mixAudio1(buffer, length);
-
 		if ((self.nr52 & 0x02) != 0):
 			self.mixAudio2(buffer, length);
-
 		if ((self.nr52 & 0x04) != 0):
 			self.mixAudio3(buffer, length);
-
 		if ((self.nr52 & 0x08) != 0):
 			self.mixAudio4(buffer, length);
 
@@ -340,18 +331,13 @@
 
 	def setAudio1Playback(self, data):
 		self.nr14 = data;
-
 		self.audio1Frequency = self.frequencyTable[self.nr13
 				+ ((self.nr14 & 0x07) << 8)];
-
 		if ((self.nr14 & 0x80) != 0):
 			self.nr52 |= 0x01;
-
 			if ((self.nr14 & 0x40) != 0 and self.audio1Length == 0):
 				self.audio1Length = (constants.SOUND_CLOCK / 256) * (64 - (self.nr11 & 0x3F));
-
 			self.audio1SweepLength = (constants.SOUND_CLOCK / 128) * ((self.nr10 >> 4) & 0x07);
-
 			self.audio1Volume = self.nr12 >> 4;
 			self.audio1EnvelopeLength = (constants.SOUND_CLOCK / 64) * (self.nr12 & 0x07);
 	
@@ -400,7 +386,6 @@
 		elif (self.nr11 & 0xC0) == 0x80:
 			wavePattern = 0x10
 		wavePattern << 22;
-
 		for index in range(0, length, 3):
 			self.audio1Index += self.audio1Frequency;
 			if ((self.audio1Index & (0x1F << 22)) >= wavePattern):
@@ -456,16 +441,12 @@
 
 	def setAudio2Playback(self, data):
 		self.nr24 = data;
-
 		self.audio2Frequency = self.frequencyTable[self.nr23\
 				+ ((self.nr24 & 0x07) << 8)];
-
 		if ((self.nr24 & 0x80) != 0):
 			self.nr52 |= 0x02;
-
 			if ((self.nr24 & 0x40) != 0 and self.audio2Length == 0):
 				self.audio2Length = (constants.SOUND_CLOCK / 256) * (64 - (self.nr21 & 0x3F));
-
 			self.audio2Volume = self.nr22 >> 4;
 			self.audio2EnvelopeLength = (constants.SOUND_CLOCK / 64) * (self.nr22 & 0x07);
 	
@@ -476,7 +457,6 @@
 			self.audio2Length-=1;
 			if (self.audio2Length <= 0):
 				self.nr52 &= ~0x02;
-
 		if (self.audio2EnvelopeLength > 0):
 			self.audio2EnvelopeLength-=1;
 
@@ -498,10 +478,8 @@
 		elif (self.nr21 & 0xC0) == 0x80:
 			wavePattern = 0x10
 		wavePattern << 22;
-		
 		for index in range(0, length):
 			self.audio2Index += self.audio2Frequency;
-
 			if ((self.audio2Index & (0x1F << 22)) >= wavePattern):
 				if ((self.nr51 & 0x20) != 0):
 					buffer[index + 0] -= self.audio2Volume;
@@ -557,9 +535,7 @@
 
 	def setAudio3Playback(self, data):
 		self.nr34 = data;
-
 		self.audio3Frequency = self.frequencyTable[((self.nr34 & 0x07) << 8) + self.nr33] >> 1;
-
 		if ((self.nr34 & 0x80) != 0 and (self.nr30 & 0x80) != 0):
 			self.nr52 |= 0x04;
 			if ((self.nr34 & 0x40) != 0 and self.audio3Length == 0):
@@ -653,13 +629,10 @@
 		self.nr44 = data;
 		if ((self.nr44 & 0x80) != 0):
 			self.nr52 |= 0x08;
-
 			if ((self.nr44 & 0x40) != 0 and self.audio4Length == 0):
 				self.audio4Length = (constants.SOUND_CLOCK / 256) * (64 - (self.nr41 & 0x3F));
-
 			self.audio4Volume = self.nr42 >> 4;
 			self.audio4EnvelopeLength = (constants.SOUND_CLOCK / 64) * (self.nr42 & 0x07);
-
 			self.audio4Index = 0;
 	
 
@@ -669,17 +642,14 @@
 			self.audio4Length-=1;
 			if (self.audio4Length <= 0):
 				self.nr52 &= ~0x08;
-
 		if (self.audio4EnvelopeLength > 0):
 			self.audio4EnvelopeLength-=1;
-
 			if (self.audio4EnvelopeLength <= 0):
 				if ((self.nr42 & 0x08) != 0):
 					if (self.audio4Volume < 15):
 						self.audio4Volume+=1;
 				elif (self.audio4Volume > 0):
 					self.audio4Volume-=1;
-
 				self.audio4EnvelopeLength += (constants.SOUND_CLOCK / 64) * (self.nr42 & 0x07);
 		
 	
@@ -687,7 +657,6 @@
 		for index in range(0, length, 2):
 			self.audio4Index += self.audio4Frequency;
 			polynomial;
-
 			if ((self.nr43 & 0x08) != 0):
 				#  7 steps
 				self.audio4Index &= 0x7FFFFF;
@@ -696,7 +665,6 @@
 				#  15 steps
 				self.audio4Index &= 0x7FFFFFFF;
 				polynomial = self.noiseStep15Table[self.audio4Index >> 21] >> ((self.audio4Index >> 16) & 31);
-		
 			if ((polynomial & 1) != 0):
 				if ((self.nr51 & 0x80) != 0):
 					buffer[index + 0] -= self.audio4Volume;
@@ -739,7 +707,6 @@
 	 # Frequency Table Generation
 	def generateFrequencyTables(self):
 		sampleRate = self.driver.getSampleRate();
-	
 		 # frequency = (4194304 / 32) / (2048 - period) Hz
 		for period in range(0, 2048):
 			skip = (((constants.GAMEBOY_CLOCK << 10) / sampleRate) << (22 - 8)) / (2048 - period);

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/video.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/video.py	Sun Mar 16 01:33:11 2008
@@ -248,12 +248,9 @@
 				self.ly = 0
 
 				self.clearFrame()
-		
-
 		# don't draw window if it was not enabled and not being drawn before
 		if ((self.lcdc & 0x20) == 0 and (data & 0x20) != 0 and self.wly == 0 and self.ly > self.wy):
 			self.wly = 144
-
 		self.lcdc = data
 
 
@@ -350,7 +347,6 @@
 				self.interrupt.raiseInterrupt(constants.LCD)
 		else:
 			self.stat &= 0xFB
-			
 		if (self.ly < 144):
 			self.stat = (self.stat & 0xFC) | 0x02
 			self.cycles += constants.MODE_2_TICKS
@@ -375,7 +371,6 @@
 	def emulateVBlank(self):
 		if (self.vblank):
 			self.vblank = False
-
 			self.stat = (self.stat & 0xFC) | 0x01
 			self.cycles += constants.MODE_1_TICKS - constants.MODE_1_BEGIN_TICKS
 			# V-Blank interrupt
@@ -439,14 +434,12 @@
 	def drawBackground(self):
 		y = (self.scy + self.ly) & 0xFF
 		x = self.scx & 0xFF
-
 		tileMap = constants.VRAM_MAP_A
 		if (self.lcdc & 0x08) != 0:
 			tileMap =  constants.VRAM_MAP_B
 		tileData = constants.VRAM_DATA_B
 		if (self.lcdc & 0x10) != 0:
 			tileData = constants.VRAM_DATA_A
-
 		tileMap += ((y >> 3) << 5) + (x >> 3)
 		tileData += (y & 7) << 1
 		self.drawTiles(8 - (x & 7), tileMap, tileData)
@@ -460,10 +453,8 @@
 			tileData = constants.VRAM_DATA_B
 			if (self.lcdc & 0x10) != 0:
 				tileData = constants.VRAM_DATA_A
-
 			tileMap += (self.wly >> 3) << 5
 			tileData += (self.wly & 7) << 1
-
 			self.drawTiles(self.wx + 1, tileMap, tileData)
 			self.wly+=1
 
@@ -690,12 +681,10 @@
 			pattern1 = self.line[x + 1]
 			pattern2 = self.line[x + 2]
 			pattern3 = self.line[x + 3]
-
 			pixels[offset + 0] = self.palette[pattern0]
 			pixels[offset + 1] = self.palette[pattern1]
 			pixels[offset + 2] = self.palette[pattern2]
 			pixels[offset + 3] = self.palette[pattern3]
-
 			offset += 4
 
 



More information about the Pypy-commit mailing list