[pypy-svn] r54425 - in pypy/branch/gameboy-emulator/pypy/lang/gameboy: . test
cami at codespeak.net
cami at codespeak.net
Sun May 4 23:37:55 CEST 2008
Author: cami
Date: Sun May 4 23:37:53 2008
New Revision: 54425
Modified:
pypy/branch/gameboy-emulator/pypy/lang/gameboy/cartridge.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboy.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/joypad.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_rom.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/video.py
Log:
completed rom tests
gameboy: fixed a nasty do-nothing-return-bug in GameBoy.read
joypad: removed the needless ( in the if statemends
video: fixed a broken function call
cpu: removed debug print statements
cartridge: fixed an unfinished variable access
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/cartridge.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/cartridge.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/cartridge.py Sun May 4 23:37:53 2008
@@ -250,7 +250,8 @@
if address <= 0x3FFF: # 0000-3FFF
return self.rom[address] & 0xFF
elif address <= 0x7FFF:# 4000-7FFF
- return self.rom[romBank + (address & 0x3FFF)] & 0xFF
+ print address, self.romBank
+ return self.rom[self.romBank + (address & 0x3FFF)] & 0xFF
elif address >= 0xA000 and address <= 0xBFFF and self.ramEnable: # A000-BFFF
return self.ram[self.ramBank + (address & 0x1FFF)] & 0xFF
return 0xFF
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py Sun May 4 23:37:53 2008
@@ -187,7 +187,11 @@
self.ime = False
self.halted = False
self.cycles = 0
-
+ self.iniRegisters()
+ self.rom = []
+ self.reset()
+
+ def iniRegisters(self):
self.b = Register(self)
self.c = Register(self)
self.bc = DoubleRegister(self, self.b, self.c, constants.RESET_BC)
@@ -208,8 +212,6 @@
self.f = FlagRegister(self)
self.af = DoubleRegister(self, self.a, self.f)
- self.rom = []
- self.reset()
def reset(self):
self.resetRegisters()
@@ -536,12 +538,10 @@
setter(data) # 1 cycle
def rotateLeftCircular(self, getter, setter):
- print "rotateLeftCircular", setter, self.cycles
# RLC 1 cycle
data = getter()
s = (data << 1) + (data >> 7)
self.flagsAndSetterFinish(s, setter, 0x80)
- print self.cycles
#self.cycles -= 1
def rotateLeftCircularA(self):
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 May 4 23:37:53 2008
@@ -95,10 +95,16 @@
ticks -= count
def write(self, address, data):
- self.getReceiver(address).write(address, data)
+ receiver = self.getReceiver(address)
+ if receiver==None:
+ raise Exception("invalid read address given")
+ receiver.write(address, data)
def read(self, address):
- self.getReceiver(address).read(address)
+ receiver = self.getReceiver(address)
+ if receiver==None:
+ raise Exception("invalid read address given")
+ return receiver.read(address)
def getReceiver(self, address):
if 0x0000 <= address <= 0x7FFF:
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/joypad.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/joypad.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/joypad.py Sun May 4 23:37:53 2008
@@ -23,18 +23,18 @@
def emulate(self, ticks):
self.cycles -= ticks
- if (self.cycles <= 0):
- if (self.driver.isRaised()):
+ if self.cycles <= 0:
+ if self.driver.isRaised():
self.update()
self.cycles = constants.JOYPAD_CLOCK
def write(self, address, data):
- if (address == constants.JOYP):
+ if address == constants.JOYP:
self.joyp = (self.joyp & 0xC) + (data & 0x3)
self.update()
def read(self, address):
- if (address == constants.JOYP):
+ if address == constants.JOYP:
return (self.joyp << 4) + self.buttonCode
return 0xFF
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_rom.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_rom.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_rom.py Sun May 4 23:37:53 2008
@@ -38,16 +38,21 @@
def test_rom4():
- py.test.skip("problem with resetBit")
gameBoy = GameBoy()
gameBoy.loadCartridgeFile(ROM_PATH+"/rom4/rom4.gb")
gameBoy.emulate(EMULATION_CYCLES)
+ assert gameBoy.cpu.ime == False
+ assert gameBoy.cpu.halted == True
+ assert gameBoy.cpu.a.get() != 0xFF
+
def test_rom5():
gameBoy = GameBoy()
gameBoy.loadCartridgeFile(ROM_PATH+"/rom5/rom5.gb")
gameBoy.emulate(EMULATION_CYCLES)
+ # stop test
+ assert gameBoy.cpu.a.get() != 0xFF
def test_rom6():
@@ -57,21 +62,18 @@
def test_rom7():
- py.test.skip("cpu bug in storeMemoryAtExpandedFetchAddressInA")
gameBoy = GameBoy()
gameBoy.loadCartridgeFile(ROM_PATH+"/rom7/rom7.gb")
gameBoy.emulate(EMULATION_CYCLES)
def test_rom8():
- py.test.skip("cpu bug in storeMemoryAtExpandedFetchAddressInA")
gameBoy = GameBoy()
gameBoy.loadCartridgeFile(ROM_PATH+"/rom8/rom8.gb")
gameBoy.emulate(EMULATION_CYCLES)
def test_rom9():
- py.test.skip("cpu bug in storeMemoryAtExpandedFetchAddressInA")
gameBoy = GameBoy()
gameBoy.loadCartridgeFile(ROM_PATH+"/rom9/rom9.gb")
gameBoy.emulate(EMULATION_CYCLES)
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 May 4 23:37:53 2008
@@ -592,5 +592,5 @@
return self.pixels
def updateDisplay(self):
- self.resetPixels()
+ self.clearPixels()
\ No newline at end of file
More information about the pypy-svn
mailing list