[pypy-svn] r54556 - in pypy/branch/gameboy-emulator/pypy/lang/gameboy: . test

cami at codespeak.net cami at codespeak.net
Thu May 8 13:54:15 CEST 2008


Author: cami
Date: Thu May  8 13:54:14 2008
New Revision: 54556

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/gameboyImplementation.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/joypad.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/sound.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cartridge.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_interrupt.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_joypad.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_register.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_rom.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/video.py
Log:
updated functions name by transforming all camelcase names to python-like
underscore names
updated test aswell


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	Thu May  8 13:54:14 2008
@@ -4,7 +4,7 @@
 from pypy.lang.gameboy import constants
 import os
 
-def hasCartridgeBattery(self, cartridgeType):    
+def has_cartridge_battery(self, cartridgeType):    
     return (cartridgeType == constants.TYPE_MBC1_RAM_BATTERY \
                 or cartridgeType == constants.TYPE_MBC2_BATTERY \
                 or cartridgeType == constants.TYPE_MBC3_RTC_BATTERY \
@@ -14,11 +14,9 @@
                 or cartridgeType == constants.TYPE_MBC5_RUMBLE_RAM_BATTERY \
                 or cartridgeType == constants.TYPE_HUC1_RAM_BATTERY)
 
-def hasCartridgeType(self, catridgeType):
-    return constants.CATRIDGE_TYPE_MAPPING.has_key(cartridgeType)    
 
-def createBankController(self, cartridgeType, rom, ram, clock):
-        if hasCartridgeType(cartridgeType):
+def create_bank_controller(self, cartridgeType, rom, ram, clock):
+        if constants.CATRIDGE_TYPE_MAPPING.has_key(cartridgeType) :
             return constants.CATRIDGE_TYPE_MAPPING[cartridgeType](rom, ram, clock)
         else:
             raise InvalidMemoryBankTypeError("Unsupported memory bank controller (0x"+hex(cartridgeType)+")")
@@ -38,7 +36,7 @@
         self.cartridge = None
         
     def reset(self):
-        if not self.hasBattery():
+        if not self.has_battery():
             self.ram[0:len(self.ram):1] = 0xFF
         self.mbc.reset()
 
@@ -51,85 +49,85 @@
     def load(self, cartridge):
         self.cartridge = cartridge
         self.rom  = self.cartridge.read()
-        self.checkROM()
-        self.createRAM()
-        self.loadBattery()
-        self.mbc = self.createBankController(self.getMemoryBankType(), self.rom, self.ram, self.clock)
+        self.check_rom()
+        self.create_ram()
+        self.load_battery()
+        self.mbc = self.create_bank_controller(self.get_memory_bank_type(), self.rom, self.ram, self.clock)
         
-    def checkROM(self):
-        if not self.verifyHeader():
+    def check_rom(self):
+        if not self.verify_header():
             raise Exeption("Cartridge header is corrupted")
-        if self.cartridge.getSize() < self.getROMSize():
+        if self.cartridge.get_size() < self.get_rom_size():
             raise Exeption("Cartridge is truncated")
         
-    def createRAM(self):
-        ramSize = self.getRAMSize()
-        if self.getMemoryBankType() >= constants.TYPE_MBC2 \
-                and self.getMemoryBankType() <= constants.TYPE_MBC2_BATTERY:
+    def create_ram(self):
+        ramSize = self.get_ram_size()
+        if self.get_memory_bank_type() >= constants.TYPE_MBC2 \
+                and self.get_memory_bank_type() <= constants.TYPE_MBC2_BATTERY:
             ramSize = 512
         self.ram = [0xFF]*ramSize
         
-    def loadBattery(self):
-        if self.cartridge.hasBattery():
-            self.ram = self.cartridge.readBattery()
+    def load_battery(self):
+        if self.cartridge.has_battery():
+            self.ram = self.cartridge.read_battery()
 
     def save(self, cartridgeName):
-        if self.cartridge.hasBattery():
-            self.cartridge.writeBattery(self.ram)
+        if self.cartridge.has_battery():
+            self.cartridge.write_battery(self.ram)
             
-    def getMemoryBankType(self):
+    def get_memory_bank_type(self):
         return self.rom[constants.CARTRIDGE_TYPE_ADDRESS] & 0xFF
     
-    def getMemoryBank(self):
+    def get_memory_bank(self):
         return self.mbc
 
-    def getROM(self):
+    def get_rom(self):
         return self.rom
         
-    def getROMSize(self):
+    def get_rom_size(self):
         romSize = self.rom[constants.CARTRIDGE_ROM_SIZE_ADDRESS] & 0xFF
         if romSize>=0x00 and romSize<=0x07:
             return 32768 << romSize
         return -1
         
-    def getRAMSize(self):
+    def get_ram_size(self):
         return constants.CARTRIDGE_RAM_SIZE_MAPPING[self.rom[constants.CARTRIDGE_RAM_SIZE_ADDRESS]]
     
-    def getDestinationCode(self):
+    def get_destination_code(self):
         return self.rom[constants.DESTINATION_CODE_ADDRESS] & 0xFF
     
-    def getLicenseeCode():
+    def get_licensee_code():
         return self.rom[constants.LICENSEE_ADDRESS] & 0xFF
 
-    def getROMVersion(self):
+    def get_rom_version(self):
         return self.rom[constants.CARTRIDGE_ROM_VERSION_ADDRESS] & 0xFF
     
-    def getHeaderChecksum(self):
+    def get_header_checksum(self):
         return self.rom[constants.HEADER_CHECKSUM_ADDRESS] & 0xFF
     
-    def getChecksum(self):
+    def get_checksum(self):
         return ((self.rom[constants.CHECKSUM_A_ADDRESS] & 0xFF) << 8) \
                 + (self.rom[constants.CHECKSUM_B_ADDRESS] & 0xFF)
     
-    def hasBattery(self):
-        return hasCartridgeBattery(self.getMemoryBankType())
+    def has_battery(self):
+        return has_cartridge_battery(self.getMemoryBankType())
     
     def verify(self):
         checksum = 0
         for address in range(len(self.rom)):
             if address is not 0x014E and address is not 0x014F:
                 checksum = (checksum + (self.rom[address] & 0xFF)) & 0xFFFF
-        return (checksum == self.getChecksum())
+        return (checksum == self.get_checksum())
     
-    def verifyHeader(self):
+    def verify_header(self):
         if len(self.rom) < 0x0150:
             return False
         checksum = 0xE7
         for address in range(0x0134, 0x014C):
             checksum = (checksum - (self.rom[address] & 0xFF)) & 0xFF
-        return (checksum == self.getHeaderChecksum())
+        return (checksum == self.get_header_checksum())
     
-    def createBankController(self, type, rom, ram, clockDriver):
+    def create_bank_controller(self, type, rom, ram, clockDriver):
         return MEMORY_BANK_MAPPING[type](rom, ram, clockDriver)
 
 
@@ -158,16 +156,16 @@
         self.cartridgeFilePath = cartridgeFilePath
         self.cartridgeName = os.path.basename(cartridgeFilePath)
         self.cartridgeFile = open(cartridgeFilePath)
-        self._loadBattery(cartridgeFilePath)
+        self._load_battery(cartridgeFilePath)
         
         
-    def _loadBattery(self, cartridgeFilePath):
-        self.batteryFilePath = self._createBatteryFilePath(cartridgeFilePath)
+    def _load_battery(self, cartridgeFilePath):
+        self.batteryFilePath = self._create_battery_file_path(cartridgeFilePath)
         self.batteryName = os.path.basename(self.batteryFilePath)
-        if self.hasBattery():
+        if self.has_battery():
             self.batteryFile = open(self.batteryFilePath)
     
-    def _createBatteryFilePath(self, cartridgeFilePath):
+    def _create_battery_file_path(self, cartridgeFilePath):
         if cartridgeFilePath.endswith(constants.CARTRIDGE_FILE_EXTENSION):
             return cartridgeFilePath.replace(constants.CARTRIDGE_FILE_EXTENSION,
                     constants.BATTERY_FILE_EXTENSION)
@@ -177,30 +175,30 @@
         else:
             return cartridgeFilePath + constants.BATTERY_FILE_EXTENSION
     
-    def hasBattery(self):
+    def has_battery(self):
         return os.path.exists(self.batteryFilePath)
     
     def read(self):
         self.cartridgeFile.seek(0)
         return map(map_to_byte, self.cartridgeFile.read())
     
-    def readBattery(self):
+    def read_battery(self):
         self.batteryFile.seek(0)
         return  map(map_to_byte, self.batteryFile.read())
     
-    def writeBattery(self, ram):
+    def write_battery(self, ram):
         self.batteryFile = open(self.batteryFilePath, "w")
         self.batteryFile.write(("").join(map(chr, ram)))
         self.batteryFile = open(self.batteryFilePath, "r+")
         
-    def removeBattery(self):
-        if self.hasBattery():
+    def remove_battery(self):
+        if self.has_battery():
             os.remove(self.batteryFilePath)
             
-    def getSize(self):
+    def get_size(self):
         return os.path.getsize(self.cartridgeFilePath)
         
-    def getBatterySize(self):
+    def get_battery_size(self):
         return os.path.getsize(self.batteryFilePath)
         
      
@@ -214,8 +212,8 @@
 class MBC(object):
     
     def __init__(self, rom, ram, clockDriver):
-        self.setROM(rom)
-        self.setRAM(ram)
+        self.set_rom(rom)
+        self.set_ram(ram)
 
     def reset(self):
         self.romBank = constants.ROM_BANK_SIZE
@@ -230,7 +228,7 @@
         self.minRamBankSize = 0
         self.maxRamBankSize = 0
     
-    def setROM(self, buffer):
+    def set_rom(self, buffer):
         banks = len(buffer) / constants.ROM_BANK_SIZE
         if banks < self.minRomBankSize or banks > self.maxRomBankSize:
             raise Exception("Invalid constants.ROM size")
@@ -238,7 +236,7 @@
         self.romSize = constants.ROM_BANK_SIZE*banks - 1
 
 
-    def setRAM(self, buffer):
+    def set_ram(self, buffer):
         banks = len(buffer) / constants.RAM_BANK_SIZE
         if banks < self.minRamBankSize or banks > self.maxRamBankSize:
             raise Exception("Invalid constants.RAM size")
@@ -301,21 +299,21 @@
 
     def write(self, address, data):
         if address <= 0x1FFF:  # 0000-1FFF
-            self.writeRAMEnable(address, data)
+            self.write_ram_enable(address, data)
         elif address <= 0x3FFF: # 2000-3FFF
-            self.writeROMBank1(address, data)
+            self.write_rom_bank_1(address, data)
         elif address <= 0x5FFF: # 4000-5FFF
-            self.writeROMBank2(address, data)
+            self.write_rom_bank_2(address, data)
         elif address <= 0x7FFF: # 6000-7FFF
             self.memoryModel = data & 0x01
         elif address >= 0xA000 and address <= 0xBFFF and self.ramEnable: # A000-BFFF
             self.ram[self.ramBank + (address & 0x1FFF)] = data
 
-    def writeRAMEnable(self, address, data):
+    def write_ram_enable(self, address, data):
         if self.ramSize > 0:
             self.ramEnable = ((data & 0x0A) == 0x0A)
     
-    def writeROMBank1(self, address, data):
+    def write_rom_bank_1(self, address, data):
         if (data & 0x1F) == 0:
             data = 1
         if self.memoryModel == 0:
@@ -323,7 +321,7 @@
         else:
             self.romBank = ((data & 0x1F) << 14) & self.romSize
         
-    def writeROMBank2(self, address, data):
+    def write_rom_bank_2(self, address, data):
         if self.memoryModel == 0:
             self.romBank = ((self.romBank & 0x07FFFF) + ((data & 0x03) << 19)) & self.romSize
         else:
@@ -363,24 +361,24 @@
 
     def write(self, address, data):
         if address <= 0x1FFF:  # 0000-1FFF
-            self.writeRAMEnable(address, data)
+            self.write_ram_enable(address, data)
         elif address <= 0x3FFF: # 2000-3FFF
-            self.writeROMBank()
+            self.write_rom_bank()
         elif address >= 0xA000 and address <= 0xA1FF: # A000-A1FF
-            self.writeRAMEnable(address, data)
+            self.write_ram(address, data)
             
-    def writeRAMEnable(self, address, data):
+    def write_ram_enable(self, address, data):
         if (address & 0x0100) == 0:
             self.ramEnable = ((data & 0x0A) == 0x0A)
             
-    def writeROMBank(self, address):
+    def write_rom_bank(self, address):
         if (address & 0x0100) == 0:
             return
         if (data & 0x0F) == 0:
             data = 1
         self.romBank = ((data & 0x0F) << 14) & self.romSize
         
-    def writeRAM(self, address, data):
+    def write_ram(self, address, data):
         if self.ramEnable:
             self.ram[address & 0x01FF] = data & 0x0F
 
@@ -425,74 +423,74 @@
             if (self.ramBank >= 0):
                 return self.ram[self.ramBank + (address & 0x1FFF)] & 0xFF
             else:
-                return self.readClockData(address)
+                return self.read_clock_data(address)
         else:
             return super.read(address)
         
-    def readClockDaata(self, address):
-        if (self.clockRegister == 0x08):
+    def read_clock_data(self, address):
+        if self.clockRegister == 0x08:
             return self.clockLSeconds
-        if (self.clockRegister == 0x09):
+        if self.clockRegister == 0x09:
             return self.clockLMinutes
-        if (self.clockRegister == 0x0A):
+        if self.clockRegister == 0x0A:
             return self.clockLHours
-        if (self.clockRegister == 0x0B):
+        if self.clockRegister == 0x0B:
             return self.clockLDays
-        if (self.clockRegister == 0x0C):
+        if self.clockRegister == 0x0C:
             return self.clockLControl
     
     def write(self, address, data):
-        if (address <= 0x1FFF): # 0000-1FFF
-            self.writeRAMEnable(address, data)
-        elif (address <= 0x3FFF): # 2000-3FFF
-            self.writeROMBank(address, data)
-        elif (address <= 0x5FFF):  # 4000-5FFF
-            self.writeRAMBank(address, data)
-        elif (address <= 0x7FFF): # 6000-7FFF
-            self.writeClockLatch(address, data)
-        elif (address >= 0xA000 and address <= 0xBFFF and self.ramEnable): # A000-BFFF
-            self.writeClockData(address, data)
+        if address <= 0x1FFF: # 0000-1FFF
+            self.write_ram_enable(address, data)
+        elif address <= 0x3FFF: # 2000-3FFF
+            self.write_rom_bank(address, data)
+        elif address <= 0x5FFF:  # 4000-5FFF
+            self.write_ram_bank(address, data)
+        elif address <= 0x7FFF: # 6000-7FFF
+            self.write_clock_latch(address, data)
+        elif address >= 0xA000 and address <= 0xBFFF and self.ramEnable: # A000-BFFF
+            self.write_clock_data(address, data)
     
-    def writeRAMEnable(self, address, data):
+    def write_ram_enable(self, address, data):
         if self.ramSize > 0:
             self.ramEnable = ((data & 0x0A) == 0x0A)
              
-    def writeROMBank(self, address, data):
+    def write_rom_bank(self, address, data):
         if data == 0:
             data = 1
         self.romBank = ((data & 0x7F) << 14) & self.romSize
             
-    def writeRAMBank(self, address, data):
-        if (data >= 0x00 and data <= 0x03):
+    def write_ram_bank(self, address, data):
+        if data >= 0x00 and data <= 0x03:
             self.ramBank = (data << 13) & self.ramSize
         else:
             self.ramBank = -1
             self.clockRegister = data
                 
-    def writeClockLatch(self, address, data):
-        if (self.clockLatch == 0 and data == 1):
+    def write_clock_latch(self, address, data):
+        if self.clockLatch == 0 and data == 1:
             self.latchClock()
-        if (data == 0 or data == 1):
+        if data == 0 or data == 1:
             self.clockLatch = data
             
-    def writeClockData(self, address, data):
-        if (self.ramBank >= 0):
+    def write_clock_data(self, address, data):
+        if self.ramBank >= 0:
             self.ram[self.ramBank + (address & 0x1FFF)] = data
         else:
             self.updateClock()
-            if (self.clockRegister == 0x08):
+            if self.clockRegister == 0x08:
                 self.clockSeconds = data
-            if (self.clockRegister == 0x09):
+            if self.clockRegister == 0x09:
                 self.clockMinutes = data
-            if (self.clockRegister == 0x0A):
+            if self.clockRegister == 0x0A:
                 self.clockHours = data
-            if (self.clockRegister == 0x0B):
+            if self.clockRegister == 0x0B:
                 self.clockDays = data
-            if (self.clockRegister == 0x0C):
+            if self.clockRegister == 0x0C:
                 self.clockControl = (self.clockControl & 0x80) | data
         
 
-    def latchClock(self):
+    def latch_clock(self):
         self.updateClock()
         self.clockLSeconds = self.clockSeconds
         self.clockLMinutes = self.clockMinutes
@@ -501,30 +499,30 @@
         self.clockLControl = (self.clockControl & 0xFE) | ((self.clockDays >> 8) & 0x01)
 
 
-    def updateClock():
-        now = self.clock.getTime()
-        if ((self.clockControl & 0x40) == 0):
+    def update_clock():
+        now = self.clock.get_time()
+        if (self.clockControl & 0x40) == 0:
             elapsed = now - self.clockTime
-            while (elapsed >= 246060):
+            while elapsed >= 246060:
                 elapsed -= 246060
                 self.clockDays+=1
-            while (elapsed >= 6060):
+            while elapsed >= 6060:
                 elapsed -= 6060
                 self.clockHours+=1
-            while (elapsed >= 60):
+            while elapsed >= 60:
                 elapsed -= 60
                 self.clockMinutes+=1
             self.clockSeconds += elapsed
-            while (self.clockSeconds >= 60):
+            while self.clockSeconds >= 60:
                 self.clockSeconds -= 60
                 self.clockMinutes+=1
-            while (self.clockMinutes >= 60):
+            while self.clockMinutes >= 60:
                 self.clockMinutes -= 60
                 self.clockHours+=1
-            while (self.clockHours >= 24):
+            while self.clockHours >= 24:
                 self.clockHours -= 24
                 self.clockDays+=1
-            while (self.clockDays >= 512):
+            while self.clockDays >= 512:
                 self.clockDays -= 512
                 self.clockControl |= 0x80
         self.clockTime = now
@@ -555,23 +553,23 @@
 
 
     def write(self, address, data):
-        if (address <= 0x1FFF):  # 0000-1FFF
+        if address <= write_ram_enable:  # 0000-1FFF
             self.writeRAMEnable(address, data)
-        elif (address <= 0x2FFF):  # 2000-2FFF
+        elif address <= 0x2FFF:  # 2000-2FFF
             self.romBank = ((self.romBank & (0x01 << 22)) + ((data & 0xFF) << 14)) & self.romSize
-        elif (address <= 0x3FFF): # 3000-3FFF
+        elif address <= 0x3FFF: # 3000-3FFF
             self.romBank = ((self.romBank & (0xFF << 14)) + ((data & 0x01) << 22)) & self.romSize
-        elif (address <= 0x4FFF):  # 4000-4FFF
-            self.writeRAMBank(address, data)
-        elif (address >= 0xA000 and address <= 0xBFFF and self.ramEnable):  # A000-BFFF
+        elif address <= 0x4FFF:  # 4000-4FFF
+            self.write_ram_bank(address, data)
+        elif address >= 0xA000 and address <= 0xBFFF and self.ramEnable:  # A000-BFFF
             self.ram[self.ramBank + (address & 0x1FFF)] = data
 
-    def writeRAMEnable(self, address, data):
-        if (self.ramSize > 0):
+    def write_ram_enable(self, address, data):
+        if self.ramSize > 0:
             self.ramEnable = ((data & 0x0A) == 0x0A)
             
-    def writeRAMBank(self, address, data):
-        if (self.rumble):
+    def write_ram_bank(self, address, data):
+        if self.rumble:
             self.ramBank = ((data & 0x07) << 13) & self.ramSize
         else:
             self.ramBank = ((data & 0x0F) << 13) & self.ramSize
@@ -612,8 +610,8 @@
         self.clockShift = 0
         self.clockTime = 0
         
-        self.setROM(rom)
-        self.setRAM(ram)
+        self.set_rom(rom)
+        self.set_ram(ram)
         self.ramFlag = 0
         self.ramValue = 0
         MBC.__init__(self, rom, ram, clockDriver)
@@ -625,11 +623,11 @@
         self.ramValue = 0
         self.clockRegister = 0
         self.clockShift = 0
-        self.clockTime = self.clock.getTime()
+        self.clockTime = self.clock.get_time()
 
 
     def read(self, address):
-        if (address >= 0xA000 and address <= 0xBFFF):# A000-BFFF
+        if address >= 0xA000 and address <= 0xBFFF:# A000-BFFF
             if (self.ramFlag == 0x0C):
                 return self.ramValue
             elif (self.ramFlag == 0x0D):
@@ -641,54 +639,54 @@
             super.read(address)
     
     def write(self, address, data):
-        if (address <= 0x1FFF): # 0000-1FFF
+        if address <= 0x1FFF: # 0000-1FFF
             self.ramFlag = data
-        elif (address <= 0x3FFF):# 2000-3FFF
+        elif address <= 0x3FFF:# 2000-3FFF
             self.writeROMBank(address, data)
-        elif (address <= 0x5FFF): # 4000-5FFF
+        elif address <= 0x5FFF: # 4000-5FFF
             self.ramBank = ((data & 0x0F) << 13) & self.ramSize
-        elif (address >= 0xA000 and address <= 0xBFFF): # A000-BFFF
+        elif address >= 0xA000 and address <= 0xBFFF: # A000-BFFF
             self.writeRAMFlag(address, data)
          
-    def writeROMBank(self, address, data):
-        if ((data & 0x7F) == 0):
+    def write_rom_bank(self, address, data):
+        if (data & 0x7F) == 0:
             data = 1
         self.romBank = ((data & 0x7F) << 14) & self.romSize
         
-    def writeRAMFlag(self, address, data):
-        if (self.ramFlag == 0x0B):
+    def write_ram_flag(self, address, data):
+        if self.ramFlag == 0x0B:
             self.writeWithRamFlag0x0B(address, data)
         elif (self.ramFlag >= 0x0C and self.ramFlag <= 0x0E):
             pass
-        elif (self.ramFlag == 0x0A and self.ramSize > 0):
+        elif self.ramFlag == 0x0A and self.ramSize > 0:
             self.ram[self.ramBank + (address & 0x1FFF)] = data
                         
-    def writeWithRamFlag0x0B(self, address, data):
-        if ((data & 0xF0) == 0x10):
-            self.writeRAMValueClockShift(address, data)
-        elif ((data & 0xF0) == 0x30):
-            self.writeClockRegisterClockShift(address, data)
-        elif ((data & 0xF0) == 0x40):
-            self.writeClockShift(address, data)
-        elif ((data & 0xF0) == 0x50):
+    def write_with_ram_flag_0x0B(self, address, data):
+        if (data & 0xF0) == 0x10:
+            self.write_ram_value_clock_shift(address, data)
+        elif (data & 0xF0) == 0x30:
+            self.write_clock_register_clock_shift(address, data)
+        elif (data & 0xF0) == 0x40:
+            self.write_clock_shift(address, data)
+        elif (data & 0xF0) == 0x50:
             pass
-        elif ((data & 0xF0) == 0x60):
+        elif (data & 0xF0) == 0x60:
             self.ramValue = 0x01
          
-    def writeRAMValueClockShift(self, address, data):
+    def write_ram_value_clock_shift(self, address, data):
         if self.clockShift > 24:
             return
         self.ramValue = (self.clockRegister >> self.clockShift) & 0x0F
         self.clockShift += 4
             
-    def writeClockRegisterClockShift(self, address, data):
+    def write_clock_register_clock_shift(self, address, data):
         if self.clockShift > 24:
             return
         self.clockRegister &= ~(0x0F << self.clockShift)
         self.clockRegister |= ((data & 0x0F) << self.clockShift)
         self.clockShift += 4
                     
-    def writeClocckShift(self, address, data):
+    def write_clock_shift(self, address, data):
         switch = data & 0x0F
         self.updateClock()
         if switch == 0:
@@ -698,24 +696,24 @@
         elif switch == 7:
             self.clockShift = 0
             
-    def updateClock(self):
+    def update_clock(self):
         now = self.clock.getTime()
         elapsed = now - self.clockTime
         # years (4 bits)
-        while (elapsed >= 365246060):
+        while elapsed >= 365246060:
             self.clockRegister += 1 << 24
             elapsed -= 365246060
         # days (12 bits)
-        while (elapsed >= 246060):
+        while elapsed >= 246060:
             self.clockRegister += 1 << 12
             elapsed -= 246060
         # minutes (12 bits)
-        while (elapsed >= 60):
+        while elapsed >= 60:
             self.clockRegister += 1
             elapsed -= 60
-        if ((self.clockRegister & 0x0000FFF) >= 2460):
+        if (self.clockRegister & 0x0000FFF) >= 2460:
             self.clockRegister += (1 << 12) - 2460
-        if ((self.clockRegister & 0x0FFF000) >= (365 << 12)):
+        if (self.clockRegister & 0x0FFF000) >= (365 << 12):
             self.clockRegister += (1 << 24) - (365 << 12)
         self.clockTime = now - elapsed
 

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	Thu May  8 13:54:14 2008
@@ -26,7 +26,7 @@
     def sub(self, value, useCycles=True):
         self.set(self.get(useCycles)-value, useCycles)
     
-# ------------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 class DoubleRegister(object):
     
@@ -44,30 +44,30 @@
         
     def set(self, hi=0, lo=None, useCycles=True):
         if lo is None:
-            self.setHi(hi >> 8, useCycles)
-            self.setLo(hi & 0xFF, useCycles)
+            self.set_hi(hi >> 8, useCycles)
+            self.set_lo(hi & 0xFF, useCycles)
             if useCycles:
                 self.cpu.cycles += 1
         else:
-            self.setHi(hi, useCycles)
-            self.setLo(lo, useCycles) 
+            self.set_hi(hi, useCycles)
+            self.set_lo(lo, useCycles) 
     
     def reset(self):
         self.set(self.resetValue, useCycles=False)
             
-    def setHi(self, hi=0, useCycles=True):
+    def set_hi(self, hi=0, useCycles=True):
         self.hi.set(hi, useCycles)
     
-    def setLo(self, lo=0, useCycles=True):
+    def set_lo(self, lo=0, useCycles=True):
         self.lo.set(lo, useCycles)
         
     def get(self, useCycles=True):
         return (self.hi.get(useCycles)<<8) + self.lo.get(useCycles)
     
-    def getHi(self, useCycles=True):
+    def get_hi(self, useCycles=True):
         return self.hi.get(useCycles)
         
-    def getLo(self, useCycles=True):
+    def get_lo(self, useCycles=True):
         return self.lo.get(useCycles)
     
     def inc(self, useCycles=True):
@@ -144,24 +144,24 @@
         if useCycles:
             self.cpu.cycles -= 1
         
-    def zFlagCompare(self, a, reset=False):
+    def z_flag_compare(self, a, reset=False):
         if (reset):
              self.reset()
         if isinstance(a, (Register)):
             a = a.get()
         self.zFlag = ((a & 0xFF) == 0)
             
-    def cFlagAdd(self, s, compareAnd=0x01, reset=False):
+    def c_flag_add(self, s, compare_and=0x01, reset=False):
         if (reset):
              self.reset()
-        if (s & compareAnd) != 0:
+        if (s & compare_and) != 0:
             self.cFlag = True
 
-    def hFlagCompare(self, a, b):
+    def h_flag_compare(self, a, b):
         if (a & 0x0F) < (b & 0x0F):
             self.hFlag = True
             
-    def cFlagCompare(self,  a, b):
+    def c_flag_compare(self,  a, b):
         if a < b:
             self.cFlag = True
         
@@ -179,11 +179,11 @@
         self.ime = False
         self.halted = False
         self.cycles = 0
-        self.iniRegisters()
+        self.ini_registers()
         self.rom = []
         self.reset()
 
-    def iniRegisters(self):
+    def ini_registers(self):
         self.b  = Register(self)
         self.c  = Register(self)
         self.bc = DoubleRegister(self, self.b, self.c, constants.RESET_BC)
@@ -206,14 +206,14 @@
         
 
     def reset(self):
-        self.resetRegisters()
+        self.reset_registers()
         self.f.reset()
         self.f.zFlag = True
         self.ime     = False
         self.halted  = False
         self.cycles  = 0
         
-    def resetRegisters(self):
+    def reset_registers(self):
         self.a.reset()
         self.f.reset()
         self.bc.reset()
@@ -222,49 +222,49 @@
         self.sp.reset()
         self.pc.reset()
         
-    def getAF(self):
+    def get_af(self):
         return self.af
         
-    def getA(self):
+    def get_a(self):
         return self.a
     
-    def getF(self):
+    def get_f(self):
         return self.f
         
-    def getBC(self):
+    def get_bc(self):
         return self.bc
     
-    def getB(self):
+    def get_b(self):
         return self.b
     
-    def getC(self):
+    def get_c(self):
         return self.c
         
-    def getDE(self):
+    def get_de(self):
         return self.de
         
-    def getD(self):
+    def get_d(self):
         return self.d
         
-    def getE(self):
+    def get_e(self):
         return self.e
         
-    def getHL(self):
+    def get_hl(self):
         return self.hl
         
-    def getHLi(self):
+    def get_hli(self):
         return self.hli
         
-    def getH(self):
+    def get_h(self):
         return self.h
         
-    def getL(self):
+    def get_l(self):
         return self.l
              
-    def getSP(self):
+    def get_sp(self):
         return self.sp
 
-    def getIF(self):
+    def get_if(self):
         val = 0x00
         if self.ime:
             val = 0x01
@@ -272,71 +272,69 @@
             val += 0x80
         return val
 
-    def isZ(self):
+    def is_z(self):
         """ zero flag"""
         return self.f.zFlag
 
-    def isC(self):
+    def is_c(self):
         """ carry flag, true if the result did not fit in the register"""
         return self.f.cFlag
 
-    def isH(self):
+    def is_h(self):
         """ half carry, carry from bit 3 to 4"""
         return self.f.hFlag
 
-    def isN(self):
+    def is_n(self):
         """ subtract flag, true if the last operation was a subtraction"""
         return self.f.nFlag
     
     def isS(self):
         return self.f.sFlag
     
-    def isP(self):
+    def is_p(self):
         return self.f.pFlag
     
-    def isNotZ(self):
-        return not self.isZ()
+    def is_not_z(self):
+        return not self.is_z()
 
-    def isNotC(self):
-        return not self.isC()
+    def is_not_c(self):
+        return not self.is_c()
     
-    def isNotH(self):
-        return not self.isH()
+    def is_not_h(self):
+        return not self.is_h()
 
-    def isNotN(self):
-        return not self.isN()
+    def is_not_n(self):
+        return not self.is_n()
 
-    def setROM(self, banks):
-                    
-        # Flags ............................................
+    def set_rom(self, banks):
         self.rom = banks       
             
     def emulate(self, ticks):
         self.cycles += ticks
-        self.handlePendingInterrupt()
+        self.handle_pending_interrupt()
         while self.cycles > 0:
             self.execute(self.fetch())
 
-    def handlePendingInterrupt(self):
+    def handle_pending_interrupt(self):
         # Interrupts
         if self.halted:
-            if self.interrupt.isPending():
+            if self.interrupt.is_pending():
                 self.halted = False
                 self.cycles -= 4
             elif (self.cycles > 0):
                 self.cycles = 0
-        if self.ime and self.interrupt.isPending():
-            self.lowerPendingInterrupt()
+        if self.ime and self.interrupt.is_pending():
+            self.lower_pending_interrupt()
             
-    def lowerPendingInterrupt(self):
+    def lower_pending_interrupt(self):
         for flag in self.interrupt.interruptFlags:
-            if flag.isPending():
+            if flag.is_pending():
                 self.ime = False
                 self.call(flag.callCode, useCycles=False)
-                flag.setPending(False)
+                flag.set_pending(False)
                 return
 
-    def fetchExecute(self):
+    def fetch_execute(self):
         # Execution
         FETCH_EXECUTE_OP_CODES[self.fetch()](self)
         
@@ -366,23 +364,23 @@
         self.pc.inc(useCycles) # 2 cycles
         return data
     
-    def fetchDoubleAddress(self):
+    def fetch_double_address(self):
         lo = self.fetch() # 1 cycle
         hi = self.fetch() # 1 cycle
         return (hi << 8) + lo
         
-    def fetchDoubleRegister(self, register):
-        self.popDoubleRegister(CPU.fetch, register)
+    def fetch_double_register(self, register):
+        self.pop_double_register(CPU.fetch, register)
 
     def push(self, data, useCycles=True):
         # Stack, 2 cycles
         self.sp.dec(useCycles) # 2 cycles
         self.memory.write(self.sp.get(useCycles), data)
         
-    def pushDoubleRegister(self, register, useCycles=True):
+    def push_double_register(self, register, useCycles=True):
         # PUSH rr 4 cycles
-        self.push(register.getHi(), useCycles) # 2 cycles
-        self.push(register.getLo(), useCycles) # 2 cycles
+        self.push(register.get_hi(), useCycles) # 2 cycles
+        self.push(register.get_lo(), useCycles) # 2 cycles
 
     def pop(self):
         # 1 cycle
@@ -391,7 +389,7 @@
         self.cycles += 1
         return data
     
-    def popDoubleRegister(self, getter, register=None):
+    def pop_double_register(self, getter, register=None):
         # 3 cycles
         if register == None:
             register = getter
@@ -403,8 +401,8 @@
         
     def call(self, address, useCycles=True):
         # 4 cycles
-        self.push(self.pc.getHi(useCycles), useCycles) # 2 cycles
-        self.push(self.pc.getLo(useCycles), useCycles) # 2 cycles
+        self.push(self.pc.get_hi(useCycles), useCycles) # 2 cycles
+        self.push(self.pc.get_lo(useCycles), useCycles) # 2 cycles
         self.pc.set(address, useCycles=useCycles)       # 1 cycle
         if useCycles:
             self.cycles += 1
@@ -413,103 +411,103 @@
         # 1 cycle
         setter(getter()) # 1 cycle
         
-    def loadFetchRegister(self, register):
+    def load_fetch_register(self, register):
         self.ld(self.fetch, register.set)
         
-    def storeHlInPC(self):
+    def store_hl_in_pc(self):
         # LD PC,HL, 1 cycle
         self.ld(self.hl.get, self.pc.set)
         
-    def fetchLoad(self, getter, setter):
+    def fetch_load(self, getter, setter):
         self.ld(self.fetch, setter)
 
-    def addA(self, getter, setter=None):
+    def add_a(self, getter, setter=None):
         # ALU, 1 cycle
         added = (self.a.get() + getter()) & 0xFF
-        self.f.zFlagCompare(added, reset=True)
-        self.f.hFlagCompare(added, self.a.get())
-        self.f.cFlagCompare(added, self.a.get())
+        self.f.z_flag_compare(added, reset=True)
+        self.f.h_flag_compare(added, self.a.get())
+        self.f.c_flag_compare(added, self.a.get())
         self.a.set(added) # 1 cycle
         
-    def addHL(self, register):
+    def add_hl(self, register):
         # 2 cycles
         a=1
         added = (self.hl.get() + register.get()) & 0xFFFF # 1 cycle
         self.f.reset(keepZ=True)
-        self.f.hFlagCompare((added >> 8), self.hl.get())
-        self.f.cFlagCompare(added, self.hl.get())
+        self.f.h_flag_compare((added >> 8), self.hl.get())
+        self.f.c_flag_compare(added, self.hl.get())
         self.hl.set(added)
         self.cycles -= 1
         
-    def addWithCarry(self, getter, setter=None):
+    def add_with_carry(self, getter, setter=None):
         # 1 cycle
         data = getter()
         s = self.a.get() + data
         if self.f.cFlag:
             s +=1
-        self.carryFlagFinish(s,data)
+        self.carry_flag_finish(s,data)
 
-    def subtractWithCarry(self, getter, setter=None):
+    def subtract_with_carry(self, getter, setter=None):
         # 1 cycle
         data = getter()
         s = self.a.get() - data
         if self.f.cFlag:
             s -= 1
-        self.carryFlagFinish(s, data)
+        self.carry_flag_finish(s, data)
         self.f.nFlag = True
         
-    def carryFlagFinish(self, s, data):
+    def carry_flag_finish(self, s, data):
         self.f.reset()
         # set the hflag if the 0x10 bit was affected
         if ((s ^ self.a.get() ^ data) & 0x10) != 0:
             self.f.hFlag = True
         if s >= 0x100:
             self.f.cFlag= True
-        self.f.zFlagCompare(s)
+        self.f.z_flag_compare(s)
         self.a.set(s)  # 1 cycle
         
-    def subtractA(self, getter, setter=None):
+    def subtract_a(self, getter, setter=None):
         # 1 cycle
-        self.compareA(getter, setter) # 1 cycle
+        self.compare_a(getter, setter) # 1 cycle
         self.a.sub(getter(useCycles=False), False)
 
-    def fetchSubtractA(self):
+    def fetch_subtract_a(self):
         data = self.fetch()
-        self.subtractA(lambda useCycles=False: data)
+        self.subtract_a(lambda useCycles=False: data)
 
-    def compareA(self, getter, setter=None):
+    def compare_a(self, getter, setter=None):
         # 1 cycle
         s = (self.a.get() - getter()) & 0xFF
         self.f.reset()
         self.f.nFlag = True
-        self.f.zFlagCompare(s)
-        self.hcFlagFinish(s)
+        self.f.z_flag_compare(s)
+        self.hc_flag_finish(s)
         self.cycles -= 1
             
-    def hcFlagFinish(self, data):
+    def hc_flag_finish(self, data):
         if data > self.a.get():
             self.f.cFlag = True
-        self.f.hFlagCompare(self.a.get(), data)
+        self.f.h_flag_compare(self.a.get(), data)
         
     def AND(self, getter, setter=None):
         # 1 cycle
         self.a.set(self.a.get() & getter())  # 1 cycle
-        self.f.zFlagCompare(self.a.get(), reset=True)
+        self.f.z_flag_compare(self.a.get(), reset=True)
 
     def XOR(self, getter, setter=None):
         # 1 cycle
         self.a.set( self.a.get() ^ getter())  # 1 cycle
-        self.f.zFlagCompare(self.a.get(), reset=True)
+        self.f.z_flag_compare(self.a.get(), reset=True)
 
     def OR(self, getter, setter=None):
         # 1 cycle
         self.a.set(self.a.get() | getter())  # 1 cycle
-        self.f.zFlagCompare(self.a.get(), reset=True)
+        self.f.z_flag_compare(self.a.get(), reset=True)
 
-    def incDoubleRegister(self, doubleRegister):
+    def inc_double_register(self, doubleRegister):
         doubleRegister.inc()
         
-    def decDoubleRegister(self, doubleRegister):
+    def dec_double_register(self, doubleRegister):
         doubleRegister.dec()
         
     def inc(self, getter, setter):
@@ -525,85 +523,85 @@
      
     def decIncFlagFinish(self, data, setter, compare):
         self.f.reset(keepC=True)
-        self.f.zFlagCompare(data)
+        self.f.z_flag_compare(data)
         if (data & 0x0F) == compare:
             self.f.hFlag = True
         setter(data) # 1 cycle
 
-    def rotateLeftCircular(self, getter, setter):
+    def rotate_left_circular(self, getter, setter):
         # RLC 1 cycle
         data = getter()
         s = (data  << 1) + (data >> 7)
-        self.flagsAndSetterFinish(s, setter, 0x80)
+        self.flags_and_setter_finish(s, setter, 0x80)
         #self.cycles -= 1
 
-    def rotateLeftCircularA(self):
-        # RLCA rotateLeftCircularA 1 cycle
-        self.rotateLeftCircular(self.a.get, self.a.set)
+    def rotate_left_circular_a(self):
+        # RLCA rotate_left_circular_a 1 cycle
+        self.rotate_left_circular(self.a.get, self.a.set)
 
-    def rotateLeft(self, getter, setter):
+    def rotate_left(self, getter, setter):
         # 1 cycle
         s = (getter() << 1) & 0xFF
         if self.f.cFlag:
             s += 0x01
-        self.flagsAndSetterFinish(s, setter, 0x80) # 1 cycle
+        self.flags_and_setter_finish(s, setter, 0x80) # 1 cycle
 
-    def rotateLeftA(self):
+    def rotate_left_a(self):
         # RLA  1 cycle
-        self.rotateLeft(self.a.get, self.a.set)
+        self.rotate_left(self.a.get, self.a.set)
         
-    def rotateRightCircular(self, getter, setter):
+    def rotate_right_circular(self, getter, setter):
         data = getter()
         # RRC 1 cycle
         s = (data >> 1) + ((data & 0x01) << 7)
-        self.flagsAndSetterFinish(s, setter) # 1 cycle
+        self.flags_and_setter_finish(s, setter) # 1 cycle
    
-    def rotateRightCircularA(self):
+    def rotate_right_circular_a(self):
         # RRCA 1 cycle
-        self.rotateRightCircular(self.a.get, self.a.set)
+        self.rotate_right_circular(self.a.get, self.a.set)
 
-    def rotateRight(self, getter, setter):
+    def rotate_right(self, getter, setter):
         # 1 cycle
         s = (getter() >> 1)
         if self.f.cFlag:
             s +=  0x08
-        self.flagsAndSetterFinish(s, setter) # 1 cycle
+        self.flags_and_setter_finish(s, setter) # 1 cycle
 
-    def rotateRightA(self):
+    def rotate_right_a(self):
         # RRA 1 cycle
-        self.rotateRight(self.a.get, self.a.set)
+        self.rotate_right(self.a.get, self.a.set)
 
-    def shiftLeftArithmetic(self, getter, setter):
+    def shift_left_arithmetic(self, getter, setter):
         # 2 cycles
         s = (getter() << 1) & 0xFF
-        self.flagsAndSetterFinish(s, setter, 0x80) # 1 cycle
+        self.flags_and_setter_finish(s, setter, 0x80) # 1 cycle
 
-    def shiftRightArithmetic(self, getter, setter):
+    def shift_right_arithmetic(self, getter, setter):
         data = getter()
         # 1 cycle
         s = (data >> 1) + (data & 0x80)
-        self.flagsAndSetterFinish(s, setter) # 1 cycle
+        self.flags_and_setter_finish(s, setter) # 1 cycle
 
-    def shiftWordRightLogical(self, getter, setter):
+    def shift_word_right_logical(self, getter, setter):
         # 2 cycles
         s = (getter() >> 1)
-        self.flagsAndSetterFinish(s, setter) # 2 cycles
+        self.flags_and_setter_finish(s, setter) # 2 cycles
         
-    def flagsAndSetterFinish(self, s, setter, compareAnd=0x01):
+    def flags_and_setter_finish(self, s, setter, compare_and=0x01):
         # 2 cycles
         s &= 0xFF
-        self.f.zFlagCompare(s,  reset=True)
-        self.f.cFlagAdd(s, compareAnd)
+        self.f.z_flag_compare(s,  reset=True)
+        self.f.c_flag_add(s, compare_and)
         setter(s) # 1 cycle
 
     def swap(self, getter, setter):
         data = getter()
         # 1 cycle
         s = ((data << 4) + (data >> 4)) & 0xFF
-        self.f.zFlagCompare(s, reset=True)
+        self.f.z_flag_compare(s, reset=True)
         setter(s)
 
-    def testBit(self, getter, setter, n):
+    def test_bit(self, getter, setter, n):
         # 2 cycles
         self.f.reset(keepC=True)
         self.f.hFlag = True
@@ -612,103 +610,103 @@
             self.f.zFlag = True
         self.cycles -= 1
 
-    def setBit(self, getter, setter, n):
+    def set_bit(self, getter, setter, n):
         # 1 cycle
         setter(getter() | (1 << n)) # 1 cycle
         
-    def resetBit(self, getter, setter, n):
+    def reset_bit(self, getter, setter, n):
         # 1 cycle
         setter(getter() & (~(1 << n))) # 1 cycle
         
-    def storeFetchedMemoryInA(self):
+    def store_fetched_memory_in_a(self):
         # LD A,(nnnn), 4 cycles
-        self.a.set(self.read(self.fetchDoubleAddress()))  # 1+1 + 2 cycles
+        self.a.set(self.read(self.fetch_double_address()))  # 1+1 + 2 cycles
 
-    def writeAAtBCAddress(self):
+    def write_a_at_bc_address(self):
         # 2 cycles
         self.write(self.bc.get(), self.a.get())
         
-    def writeAAtDEAddress(self):
+    def write_a_at_de_address(self):
         self.write(self.de.get(), self.a.get())
            
-    def storeMemoryAtBCInA(self):
+    def store_memory_at_bc_in_a(self):
         self.a.set(self.read(self.bc.get()))
 
-    def storeMemoryAtDEInA(self):
+    def store_memory_at_de_in_a(self):
         self.a.set(self.read(self.de.get()))
 
     def ld_dbRegisteri_A(self, register):
         # LD (rr),A  2 cycles
         self.write(register.get(), self.a.get()) # 2 cycles
 
-    def load_mem_SP(self):
+    def load_mem_sp(self):
         # LD (nnnn),SP  5 cycles
-        address = self.fetchDoubleAddress() # 2 cycles
-        self.write(address, self.sp.getLo())  # 2 cycles
-        self.write((address + 1), self.sp.getHi()) # 2 cycles
+        address = self.fetch_double_address() # 2 cycles
+        self.write(address, self.sp.get_lo())  # 2 cycles
+        self.write((address + 1), self.sp.get_hi()) # 2 cycles
         self.cycles += 1
 
-    def storeAAtFetchedAddress(self):
+    def store_a_at_fetched_address(self):
         # LD (nnnn),A  4 cycles
-        self.write(self.fetchDoubleAddress(), self.a.get()) # 2 cycles
+        self.write(self.fetch_double_address(), self.a.get()) # 2 cycles
 
-    def storeMemoryAtExpandedFetchAddressInA(self):
+    def store_memory_at_axpanded_fetch_address_in_a(self):
         # LDH A,(nn) 3 cycles
         self.a.set(self.read(0xFF00 + self.fetch())) # 1+1+1 cycles
         
-    def storeExpandedCinA(self):
+    def store_expanded_c_in_a(self):
         # LDH A,(C) 2 cycles
-        self.a.set(self.read(0xFF00 + self.bc.getLo())) # 1+2 cycles
+        self.a.set(self.read(0xFF00 + self.bc.get_lo())) # 1+2 cycles
         
-    def loadAndIncrement_A_HLi(self):
+    def load_and_increment_a_hli(self):
         # loadAndIncrement A,(HL) 2 cycles
         self.a.set(self.read(self.hl.get())) # 2 cycles
         self.hl.inc()# 2 cycles
         self.cycles += 2
         
-    def loadAndDecrement_A_HLi(self):
+    def load_and_decrement_a_hli(self):
         # loadAndDecrement A,(HL)  2 cycles
         self.a.set(self.read(self.hl.get())) # 2 cycles
         self.hl.dec() # 2 cycles
         self.cycles += 2
         
-    def writeAatExpandedFetchAddress(self):
+    def write_a_at_expanded_fetch_address(self):
         # LDH (nn),A 3 cycles
         self.write(0xFF00 + self.fetch(), self.a.get()) # 2 + 1 cycles
 
-    def writeAAtExpandedCAddress(self):
+    def write_a_at_expaded_c_address(self):
         # LDH (C),A 2 cycles
-        self.write(0xFF00 + self.bc.getLo(), self.a.get()) # 2 cycles
+        self.write(0xFF00 + self.bc.get_lo(), self.a.get()) # 2 cycles
         
-    def loadAndIncrement_HLi_A(self):
+    def load_and_increment_hli_a(self):
         # loadAndIncrement (HL),A 2 cycles
         self.write(self.hl.get(), self.a.get()) # 2 cycles
         self.hl.inc() # 2 cycles
         self.cycles += 2
 
-    def loadAndDecrement_HLi_A(self):
+    def load_and_decrement_hli_a(self):
         # loadAndDecrement (HL),A  2 cycles
         self.write(self.hl.get(), self.a.get()) # 2 cycles
         self.hl.dec() # 2 cycles
         self.cycles += 2
 
-    def storeHlInSp(self):
+    def store_hl_in_sp(self):
         # LD SP,HL 2 cycles
         self.sp.set(self.hl.get()) # 1 cycle
         self.cycles -= 1
 
-    def complementA(self):
+    def complement_a(self):
         # CPA
         self.a.set(self.a.get() ^ 0xFF)
         self.f.nFlag = True
         self.f.hFlag = True
 
-    def decimalAdjustAccumulator(self):
+    def decimal_adjust_accumulator(self):
         # DAA 1 cycle
         delta = 0
-        if self.isH(): 
+        if self.is_h(): 
             delta |= 0x06
-        if self.isC():
+        if self.is_c():
             delta |= 0x60
         if (self.a.get() & 0x0F) > 0x09:
             delta |= 0x06
@@ -716,34 +714,34 @@
                 delta |= 0x60
         if (self.a.get() & 0xF0) > 0x90:
             delta |= 0x60
-        if not self.isN():
+        if not self.is_n():
             self.a.set((self.a.get() + delta) & 0xFF) # 1 cycle
         else:
             self.a.set((self.a.get() - delta) & 0xFF) # 1 cycle
         self.f.reset(keepN=True)
         if delta >= 0x60:
             self.f.cFlag = True
-        self.f.zFlagCompare(self.a.get())
+        self.f.z_flag_compare(self.a.get())
 
-    def incDoubleRegister(self, register):
+    def inc_double_register(self, register):
         # INC rr
         register.inc()
 
-    def decDoubleRegister(self, register):
+    def dec_double_register(self, register):
         # DEC rr
         register.dec()
 
-    def incrementSPByFetch(self):
+    def increment_sp_by_fetch(self):
         # ADD SP,nn 4 cycles
-        self.sp.set(self.getFetchAddedSP()) # 1+1 cycle
+        self.sp.set(self.get_fetchadded_sp()) # 1+1 cycle
         self.cycles -= 2
 
-    def storeFetchAddedSPInHL(self):
+    def store_fetch_added_sp_in_hl(self):
         # LD HL,SP+nn   3  cycles
-        self.hl.set(self.getFetchAddedSP()) # 1+1 cycle
+        self.hl.set(self.get_fetchadded_sp()) # 1+1 cycle
         self.cycles -= 1
 
-    def getFetchAddedSP(self):
+    def get_fetchadded_sp(self):
         # 1 cycle
         offset = self.fetch() # 1 cycle
         s = (self.sp.get() + offset) & 0xFFFF
@@ -760,12 +758,12 @@
                 self.f.hFlag = True
         return s
 
-    def complementCarryFlag(self):
+    def complement_carry_flag(self):
         # CCF/SCF
         self.f.reset(keepZ=True, keepC=True)
         self.f.cFlag = not self.f.cFlag
 
-    def setCarryFlag(self):
+    def set_carry_flag(self):
         self.f.reset(keepZ=True)
         self.f.cFlag = True
 
@@ -773,38 +771,38 @@
         # NOP 1 cycle
         self.cycles -= 1
 
-    def unconditionalJump(self):
+    def unconditional_jump(self):
         # JP nnnn, 4 cycles
-        self.pc.set(self.fetchDoubleAddress()) # 1+2 cycles
+        self.pc.set(self.fetch_double_address()) # 1+2 cycles
         self.cycles -= 1
 
-    def conditionalJump(self, cc):
+    def conditional_jump(self, cc):
         # JP cc,nnnn 3,4 cycles
         if cc:
-            self.unconditionalJump() # 4 cycles
+            self.unconditional_jump() # 4 cycles
         else:
             self.pc.add(2) # 3 cycles
 
-    def relativeUnconditionalJump(self):
+    def relative_unconditional_jump(self):
         # JR +nn, 3 cycles
         self.pc.add(self.fetch()) # 3 + 1 cycles
         self.cycles += 1
 
-    def relativeConditionalJump(self, cc):
+    def relative_conditional_jump(self, cc):
         # JR cc,+nn, 2,3 cycles
         if cc:
-            self.relativeUnconditionalJump() # 3 cycles
+            self.relative_unconditional_jump() # 3 cycles
         else:
             self.pc.inc() # 2 cycles
     
-    def unconditionalCall(self):
+    def unconditional_call(self):
         # CALL nnnn, 6 cycles
-        self.call(self.fetchDoubleAddress())  # 4+2 cycles
+        self.call(self.fetch_double_address())  # 4+2 cycles
 
-    def conditionalCall(self, cc):
+    def conditional_call(self, cc):
         # CALL cc,nnnn, 3,6 cycles
         if cc:
-            self.unconditionalCall() # 6 cycles
+            self.unconditional_call() # 6 cycles
         else:
             self.pc.add(2) # 3 cycles
 
@@ -814,7 +812,7 @@
         hi = self.pop() # 1 cycle
         self.pc.set(hi, lo) # 2 cycles
 
-    def conditionalReturn(self, cc):
+    def conditional_return(self, cc):
         # RET cc 2,5 cycles
         if cc:
             self.ret() # 4 cycles
@@ -823,34 +821,34 @@
         else:
             self.cycles -= 2
 
-    def returnFormInterrupt(self):
+    def return_form_interrupt(self):
         # RETI 4 cycles
         self.ret() # 4 cycles
-        self.enableInterrupts() # 1 cycle + others
+        self.enable_interrups() # 1 cycle + others
         self.cycles += 1
 
     def restart(self, nn):
         # RST nn 4 cycles
         self.call(nn) # 4 cycles
 
-    def disableInterrupts(self):
+    def disable_interrups(self):
         # DI/EI 1 cycle
         self.ime = False
         self.cycles -= 1
 
-    def enableInterrupts(self):
+    def enable_interrups(self):
         # 1 cycle
         self.ime = True
         self.execute(self.fetch()) #  1
-        self.handlePendingInterrupt()
+        self.handle_pending_interrupt()
 
     def halt(self):
         # HALT/STOP
         self.halted = True
         # emulate bug when interrupts are pending
-        if (not self.ime and self.interrupt.isPending()):
+        if (not self.ime and self.interrupt.is_pending()):
             self.execute(self.memory.read(self.pc.get()))
-        self.handlePendingInterrupt()
+        self.handle_pending_interrupt()
 
     def stop(self):
         # 0 cycles
@@ -861,7 +859,7 @@
 # OPCODE LOOKUP TABLE GENERATION -----------------------------------------------
 
 
-GROUPED_REGISTERS = (CPU.getB, CPU.getC, CPU.getD, CPU.getE, CPU.getH, CPU.getL, CPU.getHLi, CPU.getA)
+GROUPED_REGISTERS = (CPU.get_b, CPU.get_c, CPU.get_d, CPU.get_e, CPU.get_h, CPU.get_l, CPU.get_hli, CPU.get_a)
 
 def create_group_op_codes(table):
     opCodes =[]
@@ -900,7 +898,7 @@
     opCode  = 0x40
     for storeRegister in GROUPED_REGISTERS:
         for loadRegister in GROUPED_REGISTERS:
-            if loadRegister != CPU.getHLi or storeRegister != CPU.getHLi:
+            if loadRegister != CPU.get_hli or storeRegister != CPU.get_hli:
                 opCodes.append((opCode, load_group_lambda(storeRegister, loadRegister)))
             opCode += 1
     return opCodes
@@ -944,51 +942,51 @@
                         
 FIRST_ORDER_OP_CODES = [
     (0x00, CPU.nop),
-    (0x08, CPU.load_mem_SP),
+    (0x08, CPU.load_mem_sp),
     (0x10, CPU.stop),
-    (0x18, CPU.relativeUnconditionalJump),
-    (0x02, CPU.writeAAtBCAddress),
-    (0x12, CPU.writeAAtDEAddress),
-    (0x22, CPU.loadAndIncrement_HLi_A),
-    (0x32, CPU.loadAndDecrement_HLi_A),
-    (0x0A, CPU.storeMemoryAtBCInA),
-    (0x1A, CPU.storeMemoryAtDEInA),
-    (0x2A, CPU.loadAndIncrement_A_HLi),
-    (0x3A, CPU.loadAndDecrement_A_HLi),
-    (0x07, CPU.rotateLeftCircularA),
-    (0x0F, CPU.rotateRightCircularA),
-    (0x17, CPU.rotateLeftA),
-    (0x1F, CPU.rotateRightA),
-    (0x27, CPU.decimalAdjustAccumulator),
-    (0x2F, CPU.complementA),
-    (0x37, CPU.setCarryFlag),
-    (0x3F, CPU.complementCarryFlag),
+    (0x18, CPU.relative_unconditional_jump),
+    (0x02, CPU.write_a_at_bc_address),
+    (0x12, CPU.write_a_at_de_address),
+    (0x22, CPU.load_and_increment_hli_a),
+    (0x32, CPU.load_and_decrement_hli_a),
+    (0x0A, CPU.store_memory_at_bc_in_a),
+    (0x1A, CPU.store_memory_at_de_in_a),
+    (0x2A, CPU.load_and_increment_a_hli),
+    (0x3A, CPU.load_and_decrement_a_hli),
+    (0x07, CPU.rotate_left_circular_a),
+    (0x0F, CPU.rotate_right_circular_a),
+    (0x17, CPU.rotate_left_a),
+    (0x1F, CPU.rotate_right_a),
+    (0x27, CPU.decimal_adjust_accumulator),
+    (0x2F, CPU.complement_a),
+    (0x37, CPU.set_carry_flag),
+    (0x3F, CPU.complement_carry_flag),
     (0x76, CPU.halt),
-    (0xF3, CPU.disableInterrupts),
-    (0xFB, CPU.enableInterrupts),
-    (0xE2, CPU.writeAAtExpandedCAddress),
-    (0xEA, CPU.storeAAtFetchedAddress),
-    (0xF2, CPU.storeExpandedCinA),
-    (0xFA, CPU.storeFetchedMemoryInA),
-    (0xC3, CPU.unconditionalJump),
+    (0xF3, CPU.disable_interrups),
+    (0xFB, CPU.enable_interrups),
+    (0xE2, CPU.write_a_at_expaded_c_address),
+    (0xEA, CPU.store_a_at_fetched_address),
+    (0xF2, CPU.store_expanded_c_in_a),
+    (0xFA, CPU.store_fetched_memory_in_a),
+    (0xC3, CPU.unconditional_jump),
     (0xC9, CPU.ret),
-    (0xD9, CPU.returnFormInterrupt),
-    (0xE9, CPU.storeHlInPC),
-    (0xF9, CPU.storeHlInSp),
-    (0xE0, CPU.writeAatExpandedFetchAddress),
-    (0xE8, CPU.incrementSPByFetch),
-    (0xF0, CPU.storeMemoryAtExpandedFetchAddressInA),
-    (0xF8, CPU.storeFetchAddedSPInHL),
-    (0xCB, CPU.fetchExecute),
-    (0xCD, CPU.unconditionalCall),
-    (0xC6, lambda s: CPU.addA(s, s.fetch)),
-    (0xCE, lambda s: CPU.addWithCarry(s,  s.fetch)),
-    (0xD6, CPU.fetchSubtractA),
-    (0xDE, lambda s: CPU.subtractWithCarry(s,  s.fetch)),
+    (0xD9, CPU.return_form_interrupt),
+    (0xE9, CPU.store_hl_in_pc),
+    (0xF9, CPU.store_hl_in_sp),
+    (0xE0, CPU.write_a_at_expanded_fetch_address),
+    (0xE8, CPU.increment_sp_by_fetch),
+    (0xF0, CPU.store_memory_at_axpanded_fetch_address_in_a),
+    (0xF8, CPU.store_fetch_added_sp_in_hl),
+    (0xCB, CPU.fetch_execute),
+    (0xCD, CPU.unconditional_call),
+    (0xC6, lambda s: CPU.add_a(s, s.fetch)),
+    (0xCE, lambda s: CPU.add_with_carry(s,  s.fetch)),
+    (0xD6, CPU.fetch_subtract_a),
+    (0xDE, lambda s: CPU.subtract_with_carry(s,  s.fetch)),
     (0xE6, lambda s: CPU.AND(s,  s.fetch)),
     (0xEE, lambda s: CPU.XOR(s,  s.fetch)),
     (0xF6, lambda s: CPU.OR(s,   s.fetch)),
-    (0xFE, lambda s: CPU.compareA(s,  s.fetch)),
+    (0xFE, lambda s: CPU.compare_a(s,  s.fetch)),
     (0xC7, lambda s: CPU.restart(s, 0x00)),
     (0xCF, lambda s: CPU.restart(s, 0x08)),
     (0xD7, lambda s: CPU.restart(s, 0x10)),
@@ -1002,47 +1000,47 @@
 REGISTER_GROUP_OP_CODES = [
     (0x04, 0x08, CPU.inc),
     (0x05, 0x08, CPU.dec),    
-    (0x06, 0x08, CPU.loadFetchRegister),
-    (0x80, 0x01, CPU.addA),    
-    (0x88, 0x01, CPU.addWithCarry),    
-    (0x90, 0x01, CPU.subtractA),    
-    (0x98, 0x01, CPU.subtractWithCarry),    
+    (0x06, 0x08, CPU.load_fetch_register),
+    (0x80, 0x01, CPU.add_a),    
+    (0x88, 0x01, CPU.add_with_carry),    
+    (0x90, 0x01, CPU.subtract_a),    
+    (0x98, 0x01, CPU.subtract_with_carry),    
     (0xA0, 0x01, CPU.AND),    
     (0xA8, 0x01, CPU.XOR),    
     (0xB0, 0x01, CPU.OR),
-    (0xB8, 0x01, CPU.compareA),
-    (0x06, 0x08, CPU.fetchLoad)
+    (0xB8, 0x01, CPU.compare_a),
+    (0x06, 0x08, CPU.fetch_load)
 ]    
         
 
-REGISTER_SET_A = [CPU.getBC, CPU.getDE, CPU.getHL, CPU.getSP]
-REGISTER_SET_B = [CPU.getBC, CPU.getDE, CPU.getHL, CPU.getAF]
-FLAG_REGISTER_SET = [CPU.isNotZ, CPU.isZ, CPU.isNotC, CPU.isC]
+REGISTER_SET_A = [CPU.get_bc, CPU.get_de, CPU.get_hl, CPU.get_sp]
+REGISTER_SET_B = [CPU.get_bc, CPU.get_de, CPU.get_hl, CPU.get_af]
+FLAG_REGISTER_SET = [CPU.is_not_z, CPU.is_z, CPU.is_not_c, CPU.is_c]
 REGISTER_OP_CODES = [ 
-    (0x01, 0x10, CPU.fetchDoubleRegister,     REGISTER_SET_A),
-    (0x09, 0x10, CPU.addHL,                   REGISTER_SET_A),
-    (0x03, 0x10, CPU.incDoubleRegister,       REGISTER_SET_A),
-    (0x0B, 0x10, CPU.decDoubleRegister,       REGISTER_SET_A),
-    (0xC0, 0x08, CPU.conditionalReturn,       FLAG_REGISTER_SET),
-    (0xC2, 0x08, CPU.conditionalJump,         FLAG_REGISTER_SET),
-    (0xC4, 0x08, CPU.conditionalCall,         FLAG_REGISTER_SET),
-    (0x20, 0x08, CPU.relativeConditionalJump, FLAG_REGISTER_SET),
-    (0xC1, 0x10, CPU.popDoubleRegister,       REGISTER_SET_B),
-    (0xC5, 0x10, CPU.pushDoubleRegister,      REGISTER_SET_B)
+    (0x01, 0x10, CPU.fetch_double_register,     REGISTER_SET_A),
+    (0x09, 0x10, CPU.add_hl,                   REGISTER_SET_A),
+    (0x03, 0x10, CPU.inc_double_register,       REGISTER_SET_A),
+    (0x0B, 0x10, CPU.dec_double_register,       REGISTER_SET_A),
+    (0xC0, 0x08, CPU.conditional_return,       FLAG_REGISTER_SET),
+    (0xC2, 0x08, CPU.conditional_jump,         FLAG_REGISTER_SET),
+    (0xC4, 0x08, CPU.conditional_call,         FLAG_REGISTER_SET),
+    (0x20, 0x08, CPU.relative_conditional_jump, FLAG_REGISTER_SET),
+    (0xC1, 0x10, CPU.pop_double_register,       REGISTER_SET_B),
+    (0xC5, 0x10, CPU.push_double_register,      REGISTER_SET_B)
 ]
 
 SECOND_ORDER_REGISTER_GROUP_OP_CODES = [
-    (0x00, 0x01, CPU.rotateLeftCircular),    
-    (0x08, 0x01, CPU.rotateRightCircular),    
-    (0x10, 0x01, CPU.rotateLeft),    
-    (0x18, 0x01, CPU.rotateRight),    
-    (0x20, 0x01, CPU.shiftLeftArithmetic),    
-    (0x28, 0x01, CPU.shiftRightArithmetic),    
+    (0x00, 0x01, CPU.rotate_left_circular),    
+    (0x08, 0x01, CPU.rotate_right_circular),    
+    (0x10, 0x01, CPU.rotate_left),    
+    (0x18, 0x01, CPU.rotate_right),    
+    (0x20, 0x01, CPU.shift_left_arithmetic),    
+    (0x28, 0x01, CPU.shift_right_arithmetic),    
     (0x30, 0x01, CPU.swap),    
-    (0x38, 0x01, CPU.shiftWordRightLogical),
-    (0x40, 0x01, CPU.testBit,  range(0, 8), 0x08),    
-    (0xC0, 0x01, CPU.setBit,   range(0, 8), 0x08),
-    (0x80, 0x01, CPU.resetBit, range(0, 8), 0x08)         
+    (0x38, 0x01, CPU.shift_word_right_logical),
+    (0x40, 0x01, CPU.test_bit,  range(0, 8), 0x08),    
+    (0xC0, 0x01, CPU.set_bit,   range(0, 8), 0x08),
+    (0x80, 0x01, CPU.reset_bit, range(0, 8), 0x08)         
 ]
 
 # RAW OPCODE TABLE INITIALIZATION ----------------------------------------------

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	Thu May  8 13:54:14 2008
@@ -4,32 +4,32 @@
 GameBoy Scheduler and Memory Mapper
 
 """
-from pypy.lang.gameboy           import constants
-from pypy.lang.gameboy.cpu       import *
+from pypy.lang.gameboy import constants
+from pypy.lang.gameboy.cpu import *
 from pypy.lang.gameboy.cartridge import *
 from pypy.lang.gameboy.interrupt import *
-from pypy.lang.gameboy.joypad    import *
-from pypy.lang.gameboy.ram       import *
-from pypy.lang.gameboy.serial    import *
-from pypy.lang.gameboy.sound     import *
-from pypy.lang.gameboy.timer     import *
-from pypy.lang.gameboy.video     import *
+from pypy.lang.gameboy.joypad import *
+from pypy.lang.gameboy.ram import *
+from pypy.lang.gameboy.serial import *
+from pypy.lang.gameboy.sound import *
+from pypy.lang.gameboy.timer import *
+from pypy.lang.gameboy.video import *
 from pypy.lang.gameboy.cartridge import *
 
 
 class GameBoy(object):
 
     def __init__(self):
-        self.createDrivers()
-        self.createGamboyElements()
+        self.create_drivers()
+        self.create_gamboy_elements()
 
-    def createDrivers(self):
+    def create_drivers(self):
         self.clock = Clock()
         self.joypadDriver = JoypadDriver()
         self.videoDriver  = VideoDriver()
         self.soundDriver  = SoundDriver()
         
-    def createGamboyElements(self): 
+    def create_gamboy_elements(self): 
         self.ram    = RAM()
         self.cartridgeManager = CartridgeManager(self.clock)
         self.interrupt = Interrupt()
@@ -40,21 +40,21 @@
         self.video  = Video(self.videoDriver, self.interrupt, self)
         self.sound  = Sound(self.soundDriver)  
 
-    def getCartridgeManager(self):
+    def get_cartridge_manager(self):
         return self.cartridgeManager
     
-    def loadCartridge(self, cartridge):
+    def load_cartridge(self, cartridge):
         self.cartridgeManager.load(cartridge)
-        self.cpu.setROM(self.cartridgeManager.getROM())
+        self.cpu.set_rom(self.cartridgeManager.get_rom())
         
-    def loadCartridgeFile(self, path):
-        self.loadCartridge(Cartridge(path))
+    def load_cartridge_file(self, path):
+        self.load_cartridge(Cartridge(path))
 
-    def getFrameSkip(self):
-        return self.video.getFrameSkip()
+    def get_frame_skip(self):
+        return self.video.get_frame_skip()
 
-    def setFrameSkip(self, frameSkip):
-        self.video.setFrameSkip(frameSkip)
+    def set_frame_skip(self, frameSkip):
+        self.video.set_frame_skip(frameSkip)
 
     def save(self, cartridgeName):
         self.cartridge.save(cartridgeName)
@@ -75,17 +75,17 @@
         self.joypad.reset()
         self.video.reset()
         self.sound.reset()
-        self.cpu.setROM(self.cartridgeManager.getROM())
+        self.cpu.set_rom(self.cartridgeManager.get_rom())
         self.drawLogo()
 
-    def cycles(self):
-        return min( self.video.getCycles(), self.serial.getCycles(),
-                    self.timer.getCycles(), self.sound.getCycles(),
-                    self.joypad.getCycles())
+    def get_cycles(self):
+        return min( self.video.get_cycles(), self.serial.get_cycles(),
+                    self.timer.get_cycles(), self.sound.get_cycles(),
+                    self.joypad.get_cycles())
 
     def emulate(self, ticks):
         while ticks > 0:
-            count = self.cycles()
+            count = self.get_cycles()
             self.cpu.emulate(count)
             self.serial.emulate(count)
             self.timer.emulate(count)
@@ -95,24 +95,24 @@
             ticks -= count
 
     def write(self, address, data):
-        receiver = self.getReceiver(address)
+        receiver = self.get_receiver(address)
         if receiver==None:
             raise Exception("invalid read address given")
         receiver.write(address, data)
 
     def read(self, address):
-        receiver = self.getReceiver(address)
+        receiver = self.get_receiver(address)
         if receiver==None:
             raise Exception("invalid read address given")
         return receiver.read(address)
 
-    def getReceiver(self, address):
+    def get_receiver(self, address):
         if 0x0000 <= address <= 0x7FFF:
-            return self.cartridgeManager.getMemoryBank()
+            return self.cartridgeManager.get_memory_bank()
         elif 0x8000 <= address <= 0x9FFF:
             return self.video
         elif 0xA000 <= address <= 0xBFFF:
-            return self.cartridgeManager.getMemoryBank()
+            return self.cartridgeManager.get_memory_bank()
         elif 0xC000 <= address <= 0xFDFF:
             return self.ram
         elif 0xFE00 <= address <= 0xFEFF:
@@ -134,7 +134,7 @@
         elif 0xFFFF <= address <= 0xFFFF:
             return self.interrupt
 
-    def drawLogo(self):
+    def draw_logo(self):
         for index in range(0, 48):
             bits = self.cartridge.read(0x0104 + index)
             pattern0 = ((bits >> 0) & 0x80) + ((bits >> 1) & 0x60)\

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboyImplementation.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboyImplementation.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/gameboyImplementation.py	Thu May  8 13:54:14 2008
@@ -16,13 +16,14 @@
 class GameBoyImplementation(GameBoy):
     
     def __init__(self):
-        self.iniWindow()
+        self.create_window()
         GameBoy.__init__(self)
         
-    def iniWindow(self):
+    def create_window(self):
         self.win = window.Window()
+        self.win.set_caption("PyBoy a GameBoy (TM)")
         
-    def createDrivers(self):
+    def create_drivers(self):
         self.clock = Clock()
         self.joypadDriver = JoypadDriverImplementation(self.win)
         self.videoDriver  = VideoDriverImplementation(self.win)
@@ -35,11 +36,11 @@
     
     def __ini__(self, win):
         JoypadDriver.__ini__(self)
-        self.crateButtonKeyCodes()
+        self.create_button_key_codes()
         self.win = win
-        self.createListeners()
+        self.create_listeners()
         
-    def crateButtonKeyCodes(self):
+    def create_button_key_codes(self):
         self.buttonKeyCodes = {key.UP    : (self.buttonUp),
                               key.RIGHT : (self.buttonRight), 
                               key.DOWN  : (self.buttonDown), 
@@ -49,21 +50,21 @@
                               key.A     : (self.buttonA), 
                               key.B     : (self.ButtonB)}
         
-    def createListeners(self):
+    def create_listeners(self):
         self.win.on_key_press = self.on_key_press
         self.win.on_key_release = self.on_key_press
         
     def on_key_press(symbol, modifiers): 
-        pressButtonFunction = self.getButton(symbol, modifiers)
+        pressButtonFunction = self.get_button_handler(symbol, modifiers)
         if pressButtonFunction != None:
             pressButtonFunction(True)
     
     def on_key_release(symbol, modifiers): 
-        pressButtonFunction = self.getButton(symbol, modifiers)
+        pressButtonFunction = self.get_button_handler(symbol, modifiers)
         if pressButtonFunction != None:
             pressButtonFunction(False)
             
-    def getButton(self, symbol, modifiers):
+    def get_button_handler(self, symbol, modifiers):
         if symbol in self.buttonKeyCodes:
             if len(self.buttonKeyCodes[symbol]) == 1 or\
                     self.buttonKeyCodes[symbol][1] ==  modifiers:
@@ -77,14 +78,15 @@
     
     def __init__(self):
         SoundDriver.__init__(self)
-        self.createSoundDriver()
+        self.create_sound_driver()
         self.enabled = True
         self.sampleRate = 44100
         self.channelCount = 2
         self.bitsPerSample = 8
 
-    def createSoundDriver(self):
-        
+    def create_sound_driver(self):
+        pass
+    
     def start(self):
         pass
         
@@ -103,21 +105,22 @@
         VideoDriver.__init__(self)
         self.win = win
         self.win.on_resize = self.on_resize
-        self.setWindowSize()
-        self.createImageBuffer()
+        self.set_window_size()
+        self.create_image_buffer()
 
-    def createImageBuffer(self):
+    def create_image_buffer(self):
         self.buffers = image.get_buffer_manager()
         self.imageBuffer = self.buffers.get_color_buffer()
         
     def on_resize(self, width, height):
         pass
     
-    def setWindowSize(self):
+    def set_window_size(self):
         self.win.setSize(self.width, self.height)
         
-    def updateDisplay(self):
-        self.clearPixels()
+    def update_display(self):
+        self.imageBuffer.blit(0, 0)
+        self.win.flip()
         
         
 # ==============================================================================

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py	Thu May  8 13:54:14 2008
@@ -10,13 +10,13 @@
         self.reset()
         
     def reset(self):
-        self._isPending = self._reset
+        self.isPending = self._reset
         
-    def isPending(self):
-        return self._isPending
+    def is_pending(self):
+        return self.isPending
     
-    def setPending(self, _isPending=True):
-        self._isPending = _isPending
+    def set_pending(self, isPending=True):
+        self.isPending = isPending
     
 
 class Interrupt(object):
@@ -27,26 +27,26 @@
     """
     
     def __init__(self):
-        self.createInterruptFlags()
-        self.createFlagList()
-        self.createFlagMaskMapping()
+        self.create_interrupt_flags()
+        self.createvflag_list()
+        self.create_flag_mask_mapping()
         self.reset()
         
-    def createInterruptFlags(self):
+    def create_interrupt_flags(self):
         self.vBlank = InterruptFlag(True, constants.VBLANK, 0x40)
         self.lcd = InterruptFlag(False, constants.LCD, 0x48)
         self.timer = InterruptFlag(False, constants.TIMER, 0x50)
         self.serial = InterruptFlag(False, constants.SERIAL, 0x58)
         self.joypad = InterruptFlag(False, constants.JOYPAD, 0x60)
         
-    def createFlagList(self):
+    def createvflag_list(self):
         self.interruptFlags = [
             self.vBlank, self.lcd, 
             self.timer, self.serial,
             self.joypad
         ]
 
-    def createFlagMaskMapping(self):
+    def create_flag_mask_mapping(self):
         self.maskMapping = {}
         for flag in self.interruptFlags:
             self.maskMapping[flag.mask] = flag
@@ -56,51 +56,51 @@
         for flag in self.interruptFlags:
             flag.reset()
 
-    def isPending(self, mask=None):
+    def is_pending(self, mask=None):
         if not self.enable:
             return False
         if mask==None:
-            return self.vBlank.isPending()
-        elif self.vBlank.isPending():
-            return self.maskMapping[mask].isPending()
+            return self.vBlank.is_pending()
+        elif self.vBlank.is_pending():
+            return self.maskMapping[mask].is_pending()
         else:
             return False
 
-    def raiseInterrupt(self, mask):
-        self.maskMapping[mask].setPending(True)
+    def raise_interrupt(self, mask):
+        self.maskMapping[mask].set_pending(True)
 
     def lower(self, mask):
-        self.maskMapping[mask].setPending(False)
+        self.maskMapping[mask].set_pending(False)
 
     def write(self, address, data):
         if  address == constants.IE:
-            self.setInterruptEnable(data)
+            self.set_interrupt_enable(data)
         elif address == constants.IF:
-            self.setInterruptFlag(data)
+            self.set_fnterrupt_flag(data)
 
     def read(self, address):
         if  address == constants.IE:
-            return self.getInterruptEnable()
+            return self.get_interrupt_enable()
         elif address == constants.IF:
-            return self.getInterruptFlag()
+            return self.get_interrupt_flag()
         return 0xFF
 
-    def getInterruptEnable(self):
+    def get_interrupt_enable(self):
         return int(self.enable)
 
-    def setInterruptEnable(self, isEnabled=True):
+    def set_interrupt_enable(self, isEnabled=True):
         self.enable = bool(isEnabled)
         
-    def getInterruptFlag(self):
+    def get_interrupt_flag(self):
         flag = 0x00
         for interruptFlag in self.interruptFlags:
-            if interruptFlag.isPending():
+            if interruptFlag.is_pending():
                 flag |= interruptFlag.mask
         return 0xE0 | flag
 
-    def setInterruptFlag(self, data):
+    def set_fnterrupt_flag(self, data):
         for flag in self.interruptFlags:
             if (data & flag.mask) != 0:
-                flag.setPending(True)
+                flag.set_pending(True)
             else:
-                flag.setPending(False)
+                flag.set_pending(False)

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	Thu May  8 13:54:14 2008
@@ -18,13 +18,13 @@
         self.buttonCode = 0xF
         self.cycles = constants.JOYPAD_CLOCK
 
-    def getCycles(self):
+    def get_cycles(self):
         return self.cycles
 
     def emulate(self, ticks):
         self.cycles -= ticks
         if self.cycles <= 0:
-            if self.driver.isRaised():
+            if self.driver.is_raised():
                 self.update()
             self.cycles = constants.JOYPAD_CLOCK
 
@@ -41,14 +41,13 @@
     def update(self):
         oldButtons = self.buttonCode
         if self.joyp == 0x1:
-            self.buttonCode = self.driver.getButtonCode()
+            self.buttonCode = self.driver.get_button_code()
         elif self.joyp == 0x2:
-            self.buttonCode = self.driver.getDirectionCode()
+            self.buttonCode = self.driver.get_direction_code()
         else:
             self.buttonCode  = 0xF
-
         if oldButtons != self.buttonCode:
-            self.interrupt.raiseInterrupt(constants.JOYPAD)
+            self.interrupt.raise_interrupt(constants.JOYPAD)
 
 
 # ------------------------------------------------------------------------------
@@ -60,10 +59,10 @@
     """
     def __init__(self):
         self.raised = False
-        self.createButtons()
+        self.create_buttons()
         self.reset()
         
-    def createButtons(self):
+    def create_buttons(self):
         self.up = Button(constants.BUTTON_UP)
         self.right = Button(constants.BUTTON_RIGHT)
         self.down = Button(constants.BUTTON_DOWN)
@@ -72,92 +71,92 @@
         self.select = Button(constants.BUTTON_SELECT)
         self.a = Button(constants.BUTTON_A)
         self.b = Button(constants.BUTTON_B)
-        self.addOppositeButtons()
-        self.createButtonGroups()
+        self.add_opposite_buttons()
+        self.create_button_groups()
         
-    def addOppositeButtons(self):
+    def add_opposite_buttons(self):
         self.up.oppositeButton = self.down
         self.down.oppositeButton = self.up
         self.left.oppositeButton = self.right
         self.right.oppositeButton = self.left
         
-    def createButtonGroups(self):
+    def create_button_groups(self):
         self.directions = [self.up, self.right, self.down, self.left]
         self.buttons = [self.start, self.select, self.a, self.b]
         
-    def getButtons(self):
+    def get_buttons(self):
         return self.buttons
     
-    def getDirections(self):
+    def get_directions(self):
         return self.directions
     
-    def getButtonCode(self):
+    def get_button_code(self):
         code = 0
         for button in self.buttons:
-            code |= button.getCode()
+            code |= button.get_code()
         return code
         
-    def getDirectionCode(self):
+    def get_direction_code(self):
         code = 0
         for button in self.directions:
-            code |= button.getCode()
+            code |= button.get_code()
         return code
     
-    def isRaised(self):
+    def is_raised(self):
         raised = self.raised
         self.raised = False
         return raised
     
     def reset(self):
         self.raised = False
-        self.releaseAllButtons()
+        self.release_all_buttons()
 
-    def releaseAllButtons(self):
-        self.releaseButtons()
-        self.releaseDirections()
+    def release_all_buttons(self):
+        self.release_buttons()
+        self.release_directions()
         
-    def releaseButtons(self):
+    def release_buttons(self):
         self.up.release()
         self.right.release()
         self.down.release()
         self.left.release()
         
-    def releaseDirections(self):
+    def release_directions(self):
         self.start.release()
         self.select.release()
         self.a.release()
         self.b.release()
         
-    def buttonUp(self, pressed=True):
-        self.up.toggleButton(pressed)
+    def button_up(self, pressed=True):
+        self.up.toggle_button(pressed)
         self.raised = True
     
-    def buttonRight(self, pressed=True):
-        self.right.toggleButton(pressed)
+    def button_right(self, pressed=True):
+        self.right.toggle_button(pressed)
         self.raised = True
     
-    def buttonDown(self, pressed=True):
-        self.down.toggleButton(pressed)
+    def button_down(self, pressed=True):
+        self.down.toggle_button(pressed)
         self.raised = True
     
-    def buttonLeft(self, pressed=True):
-        self.left.toggleButton(pressed)
+    def button_left(self, pressed=True):
+        self.left.toggle_button(pressed)
         self.raised = True
     
-    def buttonStart(self, pressed=True):
-        self.start.toggleButton(pressed)
+    def button_start(self, pressed=True):
+        self.start.toggle_button(pressed)
         self.raised = True
     
-    def buttonSelect(self, pressed=True):
-        self.select.toggleButton(pressed)
+    def button_select(self, pressed=True):
+        self.select.toggle_button(pressed)
         self.raised = True
     
-    def buttonA(self, pressed=True):
-        self.a.toggleButton(pressed)
+    def button_a(self, pressed=True):
+        self.a.toggle_button(pressed)
         self.raised = True
     
-    def buttonB(self, pressed=True):
-        self.b.toggleButton(pressed)
+    def button_b(self, pressed=True):
+        self.b.toggle_button(pressed)
         self.raised = True
     
   
@@ -171,13 +170,13 @@
         self.oppositeButton = oppositeButton
         self.pressed = False
         
-    def getCode(self):
+    def get_code(self):
         if self.pressed:
             return self.codeValue
         else:
             return 0
         
-    def toggleButton(self, pressed=True):
+    def toggle_button(self, pressed=True):
         if pressed:
             self.press()
         else:
@@ -191,5 +190,5 @@
             self.oppositeButton.release()
         self.pressed = True
         
-    def isPressed(self):
+    def is_pressed(self):
         return self.pressed
\ No newline at end of file

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py	Thu May  8 13:54:14 2008
@@ -1,3 +1,4 @@
+
 from pypy.lang.gameboy import constants
 
 class Serial(object):
@@ -15,7 +16,7 @@
         self.sb = 0x00
         self.sc = 0x00
 
-    def getCycles(self):
+    def get_cycles(self):
         return self.cycles
 
     def emulate(self, ticks):
@@ -26,32 +27,32 @@
             self.sb = 0xFF
             self.sc &= 0x7F
             self.cycles = constants.SERIAL_IDLE_CLOCK
-            self.interrupt.raiseInterrupt(constants.SERIAL)
+            self.interrupt.raise_interrupt(constants.SERIAL)
 
-    def setSerialData(self, data):
+    def set_serial_data(self, data):
         self.sb = data
 
-    def setSerialControl(self, data):
+    def set_serial_control(self, data):
         self.sc = data
         # HACK: delay the serial interrupt (Shin Nihon Pro Wrestling)
         self.cycles = constants.SERIAL_IDLE_CLOCK + constants.SERIAL_CLOCK
 
-    def getSerialData(self):
+    def get_serial_data(self):
         return self.sb
 
-    def getSerialControl(self):
+    def get_serial_control(self):
         return self.sc
 
     def write(self, address, data):
         if address == constants.SB:
-            self.setSerialData(data)
+            self.set_serial_data(data)
         elif address == constants.SC:
-            self.setSerialControl(data)
+            self.set_serial_control(data)
             
     def read(self, address):
         if address == constants.SB:
-            return self.getSerialData()
+            return self.get_serial_data()
         elif address == constants.SC:
-            return self.getSerialControl()
+            return self.get_serial_control()
         else:
             return 0xFF
\ No newline at end of file

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	Thu May  8 13:54:14 2008
@@ -32,16 +32,16 @@
     def reset(self):
         self.audioIndex = 0
     
-    def getAudioLength(self):
+    def get_audio_length(self):
         return self.audioLength
 
-    def getAudioEnvelope(self):
+    def get_audio_envelope(self):
         return self.audioEnvelope
 
-    def getAudioFrequency(self):
+    def get_audio_frequency(self):
         return self.audioFrequency
 
-    def getAudioPlayback(self):
+    def get_audio_playback(self):
         return self.audioPlayback
         
 
@@ -62,45 +62,52 @@
         self.audio1Frequency=0
     
      # Audio Channel 1
-    def getAudioSweep(self):
+    def get_audio_sweep(self):
         return self.audioSweep
 
-    def setAudioSweep(self, data):
+    def set_audio_sweep(self, data):
         self.audioSweep = data
-        self.audioSweepLength = (constants.SOUND_CLOCK / 128) * ((self.audioSweep >> 4) & 0x07)
+        self.audioSweepLength = (constants.SOUND_CLOCK / 128) * \
+                                ((self.audioSweep >> 4) & 0x07)
 
-    def setAudioLength(self, data):
+    def set_audio_length(self, data):
         self.audioLength = data
-        self.audio1Length = (constants.SOUND_CLOCK / 256) * (64 - (self.audioLength & 0x3F))
+        self.audio1Length = (constants.SOUND_CLOCK / 256) * \
+                            (64 - (self.audioLength & 0x3F))
 
-    def setAudioEnvelope(self, data):
+    def set_audio_envelope(self, data):
         self.audioEnvelope = data
         if (self.audioPlayback & 0x40) != 0:
             return
         if (self.audioEnvelope >> 4) == 0:
             self.audioVolume = 0
-        elif self.audio1EnvelopeLength == 0 and (self.audioEnvelope & 0x07) == 0:
+        elif self.audio1EnvelopeLength == 0 and \
+             (self.audioEnvelope & 0x07) == 0:
             self.audioVolume = (self.audioVolume + 1) & 0x0F
         else:
             self.audioVolume = (self.audioVolume + 2) & 0x0F
 
-    def setAudioFrequency(self, data):
+    def set_audio_frequency(self, data):
         self.audioFrequency = data
-        self.audio1Frequency = self.frequencyTable[self.audioFrequency + ((self.audioPlayback & 0x07) << 8)]
+        index = self.audioFrequency + ((self.audioPlayback & 0x07) << 8)
+        self.audio1Frequency = self.frequencyTable[index]
 
-    def setAudioPlayback(self, data):
+    def set_audio_playback(self, data):
         self.audioPlayback = data
         self.audio1Frequency = self.frequencyTable[self.audioFrequency
                 + ((self.audioPlayback & 0x07) << 8)]
         if (self.audioPlayback & 0x80) != 0:
             self.enabled = True
             if (self.audioPlayback & 0x40) != 0 and self.audio1Length == 0:
-                self.audio1Length = (constants.SOUND_CLOCK / 256) * (64 - (self.audioLength & 0x3F))
-            self.audioSweepLength = (constants.SOUND_CLOCK / 128) * ((self.audioSweep >> 4) & 0x07)
+                self.audio1Length = (constants.SOUND_CLOCK / 256) * \
+                                    (64 - (self.audioLength & 0x3F))
+            self.audioSweepLength = (constants.SOUND_CLOCK / 128) * \
+                                    ((self.audioSweep >> 4) & 0x07)
             self.audioVolume = self.audioEnvelope >> 4
-            self.audio1EnvelopeLength = (constants.SOUND_CLOCK / 64) * (self.audioEnvelope & 0x07)
+            self.audio1EnvelopeLength = (constants.SOUND_CLOCK / 64) * \
+                                        (self.audioEnvelope & 0x07)
 
-    def updateAudio(self):
+    def update_audio(self):
         if (self.audioPlayback & 0x40) != 0 and self.audio1Length > 0:
             self.audio1Length-=1
             if self.audio1Length <= 0:
@@ -113,13 +120,15 @@
                         self.audioVolume+=1
                 elif self.audioVolume > 0:
                     self.audioVolume-=1
-                self.audio1EnvelopeLength += (constants.SOUND_CLOCK / 64) * (self.audioEnvelope & 0x07)
+                self.audio1EnvelopeLength += (constants.SOUND_CLOCK / 64) * \
+                                             (self.audioEnvelope & 0x07)
         if self.audioSweepLength > 0:
             self.audioSweepLength-=1
             if self.audioSweepLength <= 0:
                 sweepSteps = (self.audioSweep & 0x07)
                 if sweepSteps != 0:
-                    frequency = ((self.audioPlayback & 0x07) << 8) + self.audioFrequency
+                    frequency = ((self.audioPlayback & 0x07) << 8) + \
+                                self.audioFrequency
                     if (self.audioSweep & 0x08) != 0:
                         frequency -= frequency >> sweepSteps
                     else:
@@ -127,13 +136,15 @@
                     if frequency < 2048:
                         self.audio1Frequency = self.frequencyTable[frequency]
                         self.audioFrequency = frequency & 0xFF
-                        self.audioPlayback = (self.audioPlayback & 0xF8) + ((frequency >> 8) & 0x07)
+                        self.audioPlayback = (self.audioPlayback & 0xF8) + \
+                                             ((frequency >> 8) & 0x07)
                     else:
                         self.audio1Frequency = 0
                         self.outputEnable &= ~0x01
-                self.audioSweepLength += (constants.SOUND_CLOCK / 128) * ((self.audioSweep >> 4) & 0x07)
+                self.audioSweepLength += (constants.SOUND_CLOCK / 128) * \
+                                         ((self.audioSweep >> 4) & 0x07)
 
-    def mixAudio(self, buffer, length):
+    def mix_audio(self, buffer, length):
         wavePattern = 0x18
         if (self.audioLength & 0xC0) == 0x00:
             wavePattern = 0x04
@@ -169,53 +180,57 @@
         self.audio2Frequency=0
       
     # Audio Channel 2
-    def setAudioLength(self, data):
+    def set_audio_length(self, data):
         self.audioLength = data
-        self.audio2Length = (constants.SOUND_CLOCK / 256) * (64 - (self.audioLength & 0x3F))
+        self.audio2Length = (constants.SOUND_CLOCK / 256) * \
+                            (64 - (self.audioLength & 0x3F))
 
-    def setAudioEnvelope(self, data):
+    def set_audio_envelope(self, data):
         self.audioEnvelope = data
         if (self.audioPlayback & 0x40) == 0:
             if (self.audioEnvelope >> 4) == 0:
                 self.audioVolume = 0
-            elif self.audio2EnvelopeLength == 0 and (self.audioEnvelope & 0x07) == 0:
+            elif self.audio2EnvelopeLength == 0 and \
+                 (self.audioEnvelope & 0x07) == 0:
                 self.audioVolume = (self.audioVolume + 1) & 0x0F
             else:
                 self.audioVolume = (self.audioVolume + 2) & 0x0F
 
-    def setAudioFrequency(self, data):
+    def set_audio_frequency(self, data):
         self.audioFrequency = data
         self.audio2Frequency = self.frequencyTable[self.audioFrequency\
                 + ((self.audioPlayback & 0x07) << 8)]
 
-    def setAudioPlayback(self, data):
+    def set_audio_playback(self, data):
         self.audioPlayback = data
         self.audio2Frequency = self.frequencyTable[self.audioFrequency\
                 + ((self.audioPlayback & 0x07) << 8)]
         if (self.audioPlayback & 0x80) != 0:
             self.enabled = True
             if (self.audioPlayback & 0x40) != 0 and self.audio2Length == 0:
-                self.audio2Length = (constants.SOUND_CLOCK / 256) * (64 - (self.audioLength & 0x3F))
+                self.audio2Length = (constants.SOUND_CLOCK / 256) * \
+                                    (64 - (self.audioLength & 0x3F))
             self.audioVolume = self.audioEnvelope >> 4
-            self.audio2EnvelopeLength = (constants.SOUND_CLOCK / 64) * (self.audioEnvelope & 0x07)
+            self.audio2EnvelopeLength = (constants.SOUND_CLOCK / 64) * \
+                                        (self.audioEnvelope & 0x07)
     
-    def updateAudio(self):
+    def update_audio(self):
         if (self.audioPlayback & 0x40) != 0 and self.audio2Length > 0:
             self.audio2Length-=1
             if self.audio2Length <= 0:
                 self.enabled = False
         if self.audio2EnvelopeLength > 0:
             self.audio2EnvelopeLength-=1
-
             if self.audio2EnvelopeLength <= 0:
                 if (self.audioEnvelope & 0x08) != 0:
                     if self.audioVolume < 15:
                         self.audioVolume+=1
                 elif self.audioVolume > 0:
                     self.audioVolume-=1
-                self.audio2EnvelopeLength += (constants.SOUND_CLOCK / 64) * (self.audioEnvelope & 0x07)
+                self.audio2EnvelopeLength += (constants.SOUND_CLOCK / 64) *\
+                                             (self.audioEnvelope & 0x07)
         
-    def mixAudio(self, buffer, length):
+    def mix_audio(self, buffer, length):
         wavePattern = 0x18
         if (self.audioLength & 0xC0) == 0x00:
             wavePattern = 0x04
@@ -243,7 +258,7 @@
     
 #SquareWaveGenerator
 class Channel3(Channel):  
-    # Audio Channel 3 int
+
     def __init__(self, sampleRate, frequencyTable):
         Channel.__init__(self, sampleRate, frequencyTable)
         self.audioEnable=0
@@ -252,56 +267,58 @@
         self.audio3Length=0
         self.audio3Frequency=0
         self.audioWavePattern = [0]*16
-   
     
-     # Audio Channel 3
-    def getAudioEnable(self):
+    def get_audio_enable(self):
         return self.audioEnable
 
-    def getAudioLevel(self):
+    def get_audio_level(self):
         return self.audioLevel
     
     #FIXME strange number here
-    def getAudio4Frequency(self):
+    def get_audio_4_frequency(self):
         return self.audioFrequency
 
-    def setAudioEnable(self, data):
+    def set_audio_enable(self, data):
         self.audioEnable = data & 0x80
         if (self.audioEnable & 0x80) == 0:
             self.enabled = False
 
-    def setAudioLength(self, data):
+    def set_audio_length(self, data):
         self.audioLength = data
-        self.audio3Length = (constants.SOUND_CLOCK / 256) * (256 - self.audioLength)
+        self.audio3Length = (constants.SOUND_CLOCK / 256) * \
+                            (256 - self.audioLength)
 
-    def setAudioLevel(self, data):
+    def set_audio_level(self, data):
         self.audioLevel = data
 
-    def setAudioFrequency(self, data):
+    def set_audio_frequency(self, data):
         self.audioFrequency = data
-        self.audio3Frequency = self.frequencyTable[((self.audioPlayback & 0x07) << 8) + self.audioFrequency] >> 1
+        index = ((self.audioPlayback & 0x07) << 8) + self.audioFrequency
+        self.audio3Frequency = self.frequencyTable[index] >> 1
 
-    def setAudioPlayback(self, data):
+    def set_audio_playback(self, data):
         self.audioPlayback = data
-        self.audio3Frequency = self.frequencyTable[((self.audioPlayback & 0x07) << 8) + self.audioFrequency] >> 1
+        index = ((self.audioPlayback & 0x07) << 8) + self.audioFrequency
+        self.audio3Frequency = self.frequencyTable[index] >> 1
         if (self.audioPlayback & 0x80) != 0 and (self.audioEnable & 0x80) != 0:
             self.enabled = True
             if (self.audioPlayback & 0x40) != 0 and self.audio3Length == 0:
-                self.audio3Length = (constants.SOUND_CLOCK / 256) * (256 - self.audioLength)
+                self.audio3Length = (constants.SOUND_CLOCK / 256) *\
+                                    (256 - self.audioLength)
     
-    def setAudioWavePattern(self, address, data):
+    def set_audio_wave_pattern(self, address, data):
         self.audioWavePattern[address & 0x0F] = data
 
-    def getAudioWavePattern(self, address):
+    def get_audio_wave_pattern(self, address):
         return self.audioWavePattern[address & 0x0F] & 0xFF
 
-    def updateAudio(self):
+    def update_audio(self):
         if (self.audioPlayback & 0x40) != 0 and self.audio3Length > 0:
             self.audio3Length-=1
             if self.audio3Length <= 0:
                 self.outputEnable &= ~0x04
 
-    def mixAudio(self, buffer, length):
+    def mix_audio(self, buffer, length):
         wavePattern = 2
         if (self.audioLevel & 0x60) == 0x00:
             wavePattern = 8
@@ -339,92 +356,99 @@
         self.audio4EnvelopeLength=0
         self.audio4Frequency=0
         
-        self.generateNoiseFrequencyRatioTable()
-        self.generateNoiseTables()
-        
+        self.generate_noise_frequency_ratio_table()
+        self.generate_noise_tables()
     
-    def generateNoiseFrequencyRatioTable(self):
-        self.noiseFreqRatioTable = [0] * 8
+    def generate_noise_frequency_ratio_table(self):
          # Polynomial Noise Frequency Ratios
          # 4194304 Hz * 1/2^3 * 2 4194304 Hz * 1/2^3 * 1 4194304 Hz * 1/2^3 *
          # 1/2 4194304 Hz * 1/2^3 * 1/3 4194304 Hz * 1/2^3 * 1/4 4194304 Hz *
          # 1/2^3 * 1/5 4194304 Hz * 1/2^3 * 1/6 4194304 Hz * 1/2^3 * 1/7
+        self.noiseFreqRatioTable = [0] * 8
         sampleFactor = ((1 << 16) / self.sampleRate)
         for ratio in range(0, 8):
             divider = 1
             if ratio != 0:
                 divider = 2 * ratio
-            self.noiseFreqRatioTable[ratio] = (constants.GAMEBOY_CLOCK / divider) *sampleFactor
+            self.noiseFreqRatioTable[ratio] = (constants.GAMEBOY_CLOCK / \
+                                             divider) *sampleFactor
 
-    # Noise Generation
-    def generateNoiseTables(self):
-        self.create7StepNoiseTable()
-        self.create15StepNoiseTable()
+    def generate_noise_tables(self):
+        self.create_7_step_noise_table()
+        self.create_15_step_noise_table()
         
-    def create7StepNoiseTable(self):
+    def create_7_step_noise_table(self):
          # Noise Tables
-        self. noiseStep7Table = [0]*4 #= new int[128 / 32]
+        self. noiseStep7Table = [0]*4
         polynomial = 0x7F
         #  7 steps
         for  index in range(0, 0x7F):
-            polynomial = (((polynomial << 6) ^ (polynomial << 5)) & 0x40) | (polynomial >> 1)
+            polynomial = (((polynomial << 6) ^ (polynomial << 5)) & 0x40) | \
+                         (polynomial >> 1)
             if (index & 31) == 0:
                 self.noiseStep7Table[index >> 5] = 0
-            self.noiseStep7Table[index >> 5] |= (polynomial & 1) << (index & 31)
+            self.noiseStep7Table[index >> 5] |= (polynomial & 1) << \
+                                                (index & 31)
             
-    def create15StepNoiseTable(self):
+    def create_15_step_noise_table(self):
         #  15 steps&
-        
-        self.noiseStep15Table = [0]*1024 #= new int[32768 / 32]
+        self.noiseStep15Table = [0]*1024
         polynomial = 0x7FFF
         for index in range(0, 0x7FFF):
-            polynomial = (((polynomial << 14) ^ (polynomial << 13)) & 0x4000) | (polynomial >> 1)
+            polynomial = (((polynomial << 14) ^ (polynomial << 13)) & \
+                         0x4000) | (polynomial >> 1)
             if (index & 31) == 0:
                 self.noiseStep15Table[index >> 5] = 0
-            self.noiseStep15Table[index >> 5] |= (polynomial & 1) << (index & 31)
+            self.noiseStep15Table[index >> 5] |= (polynomial & 1) << \
+                                                 (index & 31)
     
      # Audio Channel 4
-    def getAudioLength(self):
+    def get_audio_length(self):
         return self.audioLength
 
-    def getAudioPolynomial(self):
+    def get_audio_polynomial(self):
         return self.audioPolynomial
 
-    def getAudioPlayback(self):
+    def get_audio_playback(self):
         return self.audioPlayback
 
-    def setAudioLength(self, data):
+    def set_audio_length(self, data):
         self.audioLength = data
-        self.audio4Length = (constants.SOUND_CLOCK / 256) * (64 - (self.audioLength & 0x3F))
+        self.audio4Length = (constants.SOUND_CLOCK / 256) * \
+                            (64 - (self.audioLength & 0x3F))
 
-    def setAudioEnvelope(self, data):
+    def set_audio_envelope(self, data):
         self.audioEnvelope = data
         if (self.audioPlayback & 0x40) == 0:
             if (self.audioEnvelope >> 4) == 0:
                 self.audioVolume = 0
-            elif self.audio4EnvelopeLength == 0 and (self.audioEnvelope & 0x07) == 0:
+            elif self.audio4EnvelopeLength == 0 and \
+                 (self.audioEnvelope & 0x07) == 0:
                 self.audioVolume = (self.audioVolume + 1) & 0x0F
             else:
                 self.audioVolume = (self.audioVolume + 2) & 0x0F
 
-    def setAudioPolynomial(self, data):
+    def set_audio_polynomial(self, data):
         self.audioPolynomial = data
         if (self.audioPolynomial >> 4) <= 12:
-            self.audio4Frequency = self.noiseFreqRatioTable[self.audioPolynomial & 0x07] >> ((self.audioPolynomial >> 4) + 1)
+            freq = self.noiseFreqRatioTable[self.audioPolynomial & 0x07]
+            self.audio4Frequency = freq >> ((self.audioPolynomial >> 4) + 1)
         else:
             self.audio4Frequency = 0
 
-    def setAudioPlayback(self, data):
+    def set_audio_playback(self, data):
         self.audioPlayback = data
         if (self.audioPlayback & 0x80) != 0:
             self.enabled = True
             if (self.audioPlayback & 0x40) != 0 and self.audio4Length == 0:
-                self.audio4Length = (constants.SOUND_CLOCK / 256) * (64 - (self.audioLength & 0x3F))
+                self.audio4Length = (constants.SOUND_CLOCK / 256) * \
+                                    (64 - (self.audioLength & 0x3F))
             self.audioVolume = self.audioEnvelope >> 4
-            self.audio4EnvelopeLength = (constants.SOUND_CLOCK / 64) * (self.audioEnvelope & 0x07)
+            self.audio4EnvelopeLength = (constants.SOUND_CLOCK / 64) * \
+                                        (self.audioEnvelope & 0x07)
             self.audio4Index = 0
 
-    def updateAudio(self):
+    def update_audio(self):
         if (self.audioPlayback & 0x40) != 0 and self.audio4Length > 0:
             self.audio4Length-=1
             if self.audio4Length <= 0:
@@ -437,20 +461,23 @@
                         self.audioVolume+=1
                 elif self.audioVolume > 0:
                     self.audioVolume-=1
-                self.audio4EnvelopeLength += (constants.SOUND_CLOCK / 64) * (self.audioEnvelope & 0x07)
+                self.audio4EnvelopeLength += (constants.SOUND_CLOCK / 64) *\
+                                             (self.audioEnvelope & 0x07)
     
-    def mixAudio(self, buffer, length):
+    def mix_audio(self, buffer, length):
         for index in range(0, length, 2):
             self.audio4Index += self.audio4Frequency
             polynomial
             if (self.audioPolynomial & 0x08) != 0:
                 #  7 steps
                 self.audio4Index &= 0x7FFFFF
-                polynomial = self.noiseStep7Table[self.audio4Index >> 21] >> ((self.audio4Index >> 16) & 31)
+                polynomial = self.noiseStep7Table[self.audio4Index >> 21] >>\
+                             ((self.audio4Index >> 16) & 31)
             else:
                 #  15 steps
                 self.audio4Index &= 0x7FFFFFFF
-                polynomial = self.noiseStep15Table[self.audio4Index >> 21] >> ((self.audio4Index >> 16) & 31)
+                polynomial = self.noiseStep15Table[self.audio4Index >> 21] >> \
+                             ((self.audio4Index >> 16) & 31)
             if (polynomial & 1) != 0:
                 if (self.outputTerminal & 0x80) != 0:
                     buffer[index + 0] -= self.audioVolume
@@ -476,25 +503,26 @@
         self.outputEnable=0
         
         self.driver = soundDriver
-        self.sampleRate =  self.driver.getSampleRate()
+        self.sampleRate =  self.driver.get_sample_rate()
         
-        self.generateFrequencyTable()
-        self.createAudioChannels()
+        self.generate_frequency_table()
+        self.create_audio_channels()
         
         self.reset()
         
-    def createAudioChannels(self):
+    def create_audio_channels(self):
         self.channel1 = Channel1(self.sampleRate, self.frequencyTable)
         self.channel2 = Channel2(self.sampleRate, self.frequencyTable)
         self.channel3 = Channel3(self.sampleRate, self.frequencyTable)
         self.channel4 = NoiseGenerator(self.sampleRate, self.frequencyTable)
         
         
-    def generateFrequencyTable(self):
+    def generate_frequency_table(self):
         self.frequencyTable = [0] * 2048
          # frequency = (4194304 / 32) / (2048 - period) Hz
         for period in range(0, 2048):
-            skip = (((constants.GAMEBOY_CLOCK << 10) / self.sampleRate) << 16) / (2048 - period)
+            skip = (((constants.GAMEBOY_CLOCK << 10) / \
+                   self.sampleRate) << 16) / (2048 - period)
             if skip >= (32 << 22):
                 self.frequencyTable[period] = 0
             else:
@@ -551,178 +579,178 @@
     def stop(self):
         self.driver.stop()
 
-    def getCycles(self):
+    def get_cycles(self):
         return self.cycles
 
     def emulate(self, ticks):
         self.cycles -= ticks
         while (self.cycles <= 0):
-            self.updateAudio()
+            self.update_audio()
             if self.driver.isEnabled():
-                self.mixDownAudio()
+                self.mix_down_audio()
             self.cycles += constants.GAMEBOY_CLOCK / constants.SOUND_CLOCK
             
-    def mixDownAudio(self):
-        self.frames += self.driver.getSampleRate()
+    def mix_down_audio(self):
+        self.frames += self.driver.get_sample_rate()
         length = (self.frames / constants.SOUND_CLOCK) << 1
-        self.mixAudio(self.buffer, length)
+        self.mix_audio(self.buffer, length)
         self.driver.write(self.buffer, length)
         self.frames %= constants.SOUND_CLOCK
         
     def read(self, address):
         if address==constants.NR10:
-            return self.channel1.getAudioSweep()
+            return self.channel1.get_audio_sweep()
         elif address == constants.NR11:
-            return self.channel1.getAudioLength()
+            return self.channel1.get_audio_length()
         elif address == constants.NR12:
-            return self.channel1.getAudioEnvelope()
+            return self.channel1.get_audio_envelope()
         elif address == constants.NR13:
-            return self.channel1.getAudioFrequency()
+            return self.channel1.get_audio_frequency()
         elif address == constants.NR14:
-            return self.channel1.getAudioPlayback()
+            return self.channel1.get_audio_playback()
 
         elif address == constants.NR21:
-            return self.channel2.getAudioLength()
+            return self.channel2.get_audio_length()
         elif address == constants.NR22:
-            return self.channel2.getAudioEnvelope()
+            return self.channel2.get_audio_envelope()
         elif address==constants.NR23:
-            return self.channel2.getAudioFrequency()
+            return self.channel2.get_audio_frequency()
         elif address==constants.NR24:
-            return self.channel2.getAudioPlayback()
+            return self.channel2.get_audio_playback()
 
         elif address==constants.NR30:
-            return self.channel3.getAudioEnable()
+            return self.channel3.get_audio_enable()
         elif address==constants.NR31:
-            return self.channel3.getAudioLength()
+            return self.channel3.get_audio_length()
         elif address==constants.NR32:
-            return self.channel3.getAudioLevel()
+            return self.channel3.get_audio_level()
         elif address==constants.NR33:
-            return self.channel4.getAudioFrequency()
+            return self.channel4.get_audio_frequency()
         elif address==constants.NR34:
-            return self.channel3.getAudioPlayback()
+            return self.channel3.get_audio_playback()
 
         elif address==constants.NR41:
-            return self.channel4.getAudioLength()
+            return self.channel4.get_audio_length()
         elif address==constants.NR42:
-            return self.channel4.getAudioEnvelope()
+            return self.channel4.get_audio_envelope()
         elif address==constants.NR43:
-            return self.channel4.getAudioPolynomial()
+            return self.channel4.get_audio_polynomial()
         elif address==constants.NR44:
-            return self.channel4.getAudioPlayback()
+            return self.channel4.get_audio_playback()
 
         elif address==constants.NR50:
-            return self.getOutputLevel()
+            return self.get_output_level()
         elif address==constants.NR51:
-            return self.getOutputTerminal()
+            return self.get_output_terminal()
         elif address==constants.NR52:
-            return self.getOutputEnable()
+            return self.get_output_enable()
 
-        elif (address >= constants.AUD3WAVERAM and address <= constants.AUD3WAVERAM + 0x3F):
-            return self.channel3.getAudioWavePattern(address)
+        elif address >= constants.AUD3WAVERAM and \
+             address <= constants.AUD3WAVERAM + 0x3F:
+            return self.channel3.get_audio_wave_pattern(address)
         return 0xFF
 
     def write(self, address, data):
         if address==constants.NR10:
-            self.channel1.setAudioSweep(data)
+            self.channel1.set_audio_sweep(data)
         elif address == constants.NR11:
-            self.channel1.setAudioLength(data)
+            self.channel1.set_audio_length(data)
         elif address == constants.NR12:
-            self.channel1.setAudioEnvelope(data)
+            self.channel1.set_audio_envelope(data)
         elif address == constants.NR13:
-            self.channel1.setAudioFrequency(data)
+            self.channel1.set_audio_frequency(data)
         elif address == constants.NR14:
-            self.channel1.setAudioPlayback(data)
+            self.channel1.set_audio_playback(data)
         
         elif address == constants.NR21:
-            self.channel2.setAudioLength(data)
+            self.channel2.set_audio_length(data)
         elif address == constants.NR22:
-            self.channel2.setAudioEnvelope(data)
+            self.channel2.set_audio_envelope(data)
         elif address == constants.NR23:
-            self.channel2.setAudioFrequency(data)
+            self.channel2.set_audio_frequency(data)
         elif address == constants.NR24:
-            self.channel2.setAudioPlayback(data)
+            self.channel2.set_audio_playback(data)
         
         elif address == constants.NR30:
-            self.channel3.setAudioEnable(data)
+            self.channel3.set_audio_enable(data)
         elif address == constants.NR31:
-            self.channel3.setAudioLength(data)
+            self.channel3.set_audio_length(data)
         elif address == constants.NR32:
-            self.channel3.setAudioLevel(data)
+            self.channel3.set_audio_level(data)
         elif address == constants.NR33:
-            self.channel3.setAudioFrequency(data)
+            self.channel3.set_audio_frequency(data)
         elif address == constants.NR34:
-            self.channel3.setAudioPlayback(data)
+            self.channel3.set_audio_playback(data)
         
         elif address == constants.NR41:
-            self.channel4.setAudioLength(data)
+            self.channel4.set_audio_length(data)
         elif address == constants.NR42:
-            self.channel4.setAudioEnvelope(data)
+            self.channel4.set_audio_envelope(data)
         elif address == constants.NR43:
-            self.channel4.setAudioPolynomial(data)
+            self.channel4.set_audio_polynomial(data)
         elif address == constants.NR44:
-            self.channel4.setAudioPlayback(data)
+            self.channel4.set_audio_playback(data)
         
         elif address == constants.NR50:
-            self.setOutputLevel(data)
+            self.set_output_level(data)
         elif address == constants.NR51:
-            self.setOutputTerminal(data)
+            self.set_output_terminal(data)
         elif address == constants.NR52:
-            self.setOutputEnable(data)
+            self.set_output_enable(data)
         
-        elif (address >= constants.AUD3WAVERAM and address <= constants.AUD3WAVERAM + 0x3F):
-            self.channel3.setAudioWavePattern(address, data)
+        elif address >= constants.AUD3WAVERAM and \
+             address <= constants.AUD3WAVERAM + 0x3F:
+            self.channel3.set_audio_wave_pattern(address, data)
 
-    def updateAudio(self):
+    def update_audio(self):
         if (self.outputEnable & 0x80) == 0:
             return
         if (self.outputEnable & 0x01) != 0:
-            self.channel1.updateAudio()
+            self.channel1.update_audio()
         if (self.outputEnable & 0x02) != 0:
-            self.channel2.updateAudio()
+            self.channel2.update_audio()
         if (self.outputEnable & 0x04) != 0:
-            self.channel3.updateAudio()
+            self.channel3.update_audio()
         if (self.outputEnable & 0x08) != 0:
-            self.channel4.updateAudio()
+            self.channel4.update_audio()
 
-    def mixAudio(self, buffer, length):
+    def mix_audio(self, buffer, length):
         if (self.outputEnable & 0x80) == 0:
             return
         if (self.outputEnable & 0x01) != 0:
-            self.channel1.mixAudio(buffer, length)
+            self.channel1.mix_audio(buffer, length)
         if (self.outputEnable & 0x02) != 0:
-            self.channel2.mixAudio(buffer, length)
+            self.channel2.mix_audio(buffer, length)
         if (self.outputEnable & 0x04) != 0:
-            self.channel3.mixAudio(buffer, length)
+            self.channel3.mix_audio(buffer, length)
         if (self.outputEnable & 0x08) != 0:
-            self.channel4.mixAudio(buffer, length)
+            self.channel4.mix_audio(buffer, length)
 
      # Output Control
-    def getOutputLevel(self):
+    def get_output_level(self):
         return self.outputLevel
 
-    def getOutputTerminal(self):
+    def get_output_terminal(self):
         return self.outputTerminal
 
-    def getOutputEnable(self):
+    def get_output_enable(self):
         return self.outputEnable
 
-    def setOutputLevel(self, data):
+    def set_output_level(self, data):
         self.outputLevel = data
 
-    def setOutputTerminal(self, data):
+    def set_output_terminal(self, data):
         self.outputTerminal = data
 
-    def setOutputEnable(self, data):
+    def set_output_enable(self, data):
         self.outputEnable = (self.outputEnable & 0x7F) | (data & 0x80)
-        if ((self.outputEnable & 0x80) == 0x00):
+        if (self.outputEnable & 0x80) == 0x00:
             self.outputEnable &= 0xF0
 
 
- 
-            
-            
 # SOUND DRIVER -----------------------------------------------------------------
 
+
 class SoundDriver(object):
     
     def __init__(self):
@@ -731,16 +759,16 @@
         self.channelCount = 2
         self.bitsPerSample = 8
     
-    def isEnabled(self):
+    def is_enabled(self):
         return self.enabled
     
-    def getSampleRate(self):
+    def get_sample_rate(self):
         return self.sampleRate
     
-    def getChannels(self):
+    def get_channels(self):
         return self.channelCount
     
-    def getBitsPerSample(self):
+    def get_bits_per_sample(self):
         return self.bitsPerSample
     
     def start(self):

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cartridge.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cartridge.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cartridge.py	Thu May  8 13:54:14 2008
@@ -64,7 +64,7 @@
     
     assert cartridge.batteryName == romFile+constants.BATTERY_FILE_EXTENSION
     assert cartridge.batteryFilePath ==  romFilePath+constants.BATTERY_FILE_EXTENSION
-    assert cartridge.hasBattery() == False
+    assert cartridge.has_battery() == False
     assert cartridge.batteryFile == None
     
     
@@ -75,7 +75,7 @@
     romFilePath = ROM_PATH+"/rom1/"+romName
     
     cartridge.load(romFilePath)
-    assert cartridge.hasBattery() == False
+    assert cartridge.has_battery() == False
     
     
 def test_cartridge_read():
@@ -92,17 +92,17 @@
     romFilePath = ROM_PATH + "/rom1/"+romName
     
     cartridge.load(romFilePath)
-    cartridge.removeBattery()
-    assert cartridge.hasBattery() == False
+    cartridge.remove_battery()
+    assert cartridge.has_battery() == False
     
-    cartridge.writeBattery(MAPPED_CONTENT)
-    assert cartridge.hasBattery() == True
+    cartridge.write_battery(MAPPED_CONTENT)
+    assert cartridge.has_battery() == True
     print cartridge.batteryFile
     assert cartridge.batteryFile.read() == CONTENT
-    assert cartridge.readBattery() == MAPPED_CONTENT
+    assert cartridge.read_battery() == MAPPED_CONTENT
     
-    cartridge.removeBattery()
-    assert cartridge.hasBattery() == False
+    cartridge.remove_battery()
+    assert cartridge.has_battery() == False
     
     
     

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py	Thu May  8 13:54:14 2008
@@ -20,7 +20,7 @@
 def get_cpu(new=False):
     if new:
         cpu = CPU(Interrupt(), Memory())
-        cpu.setROM([0]*0xFFFF);
+        cpu.set_rom([0]*0xFFFF);
         return cpu
     global TEST_CPU
     if TEST_CPU == None:
@@ -91,20 +91,20 @@
     assert cpu.read(address) == value
     
 
-def test_relativeConditionalJump():
+def test_relative_conditional_jump():
     cpu = get_cpu()
     pc = cpu.pc.get()
     value = 0x12
     cpu.rom[constants.RESET_PC] = value
     # test jr_nn
     startCycles = cpu.cycles
-    cpu.relativeConditionalJump(True)
+    cpu.relative_conditional_jump(True)
     assert startCycles-cpu.cycles == 3
     assert_registers(cpu, pc=pc+value+1)
     # test pc.inc
     startCycles = cpu.cycles
     pc = cpu.pc.get()
-    cpu.relativeConditionalJump(False)
+    cpu.relative_conditional_jump(False)
     assert startCycles-cpu.cycles == 2
     assert cpu.pc.get() == pc+1
     
@@ -112,28 +112,28 @@
 def test_flags():
     cpu = get_cpu()
     cpu.f.set(constants.Z_FLAG)
-    assert cpu.isZ() == True
-    assert cpu.isNotZ() == False
+    assert cpu.is_z() == True
+    assert cpu.is_not_z() == False
     cpu.f.set(~constants.Z_FLAG)
-    assert cpu.isZ() == False
-    assert cpu.isNotZ() == True
+    assert cpu.is_z() == False
+    assert cpu.is_not_z() == True
     
     cpu.f.set(constants.C_FLAG)
-    assert cpu.isC() == True
-    assert cpu.isNotC() == False
+    assert cpu.is_c() == True
+    assert cpu.is_not_c() == False
     cpu.f.set(~constants.C_FLAG)
-    assert cpu.isC() == False
-    assert cpu.isNotC() == True
+    assert cpu.is_c() == False
+    assert cpu.is_not_c() == True
  
 def test_flags_memory_access(): 
     cpu = get_cpu()
     cpu.f.set(constants.Z_FLAG)
-    assert cpu.isZ() == True
+    assert cpu.is_z() == True
     prepare_for_fetch(cpu, 0x1234, 0x1234)
     cpu.memory.write(0x1234, 0x12)
-    assert cpu.isZ() == True
+    assert cpu.is_z() == True
     cpu.rom[0x1234] = 0x12
-    assert cpu.isZ() == True
+    assert cpu.is_z() == True
    
 
 def fetch_execute_cycle_test(cpu, opCode, cycles=0):
@@ -183,8 +183,8 @@
 def test_create_register_op_codes():
     start = 0x09
     step = 0x10
-    func = CPU.addHL
-    registers = [CPU.getBC]*128
+    func = CPU.add_hl
+    registers = [CPU.get_bc]*128
     table = [(start, step, func, registers)]
     list = create_register_op_codes(table)
     opCode = start
@@ -308,8 +308,8 @@
     cpu.sp.set(0x1234)
     cycle_test(cpu, 0x08, 5)
     assert_default_registers(cpu, pc=startPC+2, sp=0x1234)
-    assert cpu.memory.read(0xCDEF) == cpu.sp.getLo()
-    assert cpu.memory.read(0xCDEF+1) == cpu.sp.getHi()
+    assert cpu.memory.read(0xCDEF) == cpu.sp.get_lo()
+    assert cpu.memory.read(0xCDEF+1) == cpu.sp.get_hi()
     
 # stop
 def test_0x10():
@@ -358,8 +358,8 @@
     for index in range(0, len(registers)):
         prepare_for_fetch(cpu, value, value+1)
         cycle_test(cpu, opCode, 3)
-        assert registers[index].getLo() == value+1
-        assert registers[index].getHi() == value
+        assert registers[index].get_lo() == value+1
+        assert registers[index].get_hi() == value
         value += 3
         opCode += 0x10
         
@@ -774,13 +774,13 @@
     
     cpu.a.set(0)
     cpu.b.set(0)
-    cpu.addA(cpu.b.get, cpu.b.set)
+    cpu.add_a(cpu.b.get, cpu.b.set)
     assert_default_flags(cpu, zFlag=True, hFlag=False)
     
     cpu.reset()
     cpu.a.set(0x0F)
     cpu.b.set(0x01)
-    cpu.addA(cpu.b.get, cpu.b.set)
+    cpu.add_a(cpu.b.get, cpu.b.set)
     assert_default_flags(cpu, zFlag=False, hFlag=True)
     
     
@@ -815,7 +815,7 @@
     cpu.reset()
     a.set(0)
     b.set(0)
-    cpu.addWithCarry(b.get, b.set)
+    cpu.add_with_carry(b.get, b.set)
     assert_default_registers(cpu, a=0, f=None)
     assert_default_flags(cpu, zFlag=True, cFlag=False, hFlag=False)
     
@@ -823,14 +823,14 @@
     a.set(0)
     b.set(0)
     cpu.f.cFlag = True
-    cpu.addWithCarry(b.get, b.set)
+    cpu.add_with_carry(b.get, b.set)
     assert_default_registers(cpu, a=1, f=None)
     assert_default_flags(cpu, zFlag=False, cFlag=False, hFlag=False)
     
     cpu.reset()
     a.set(0xF0)
     b.set(0xFF)
-    cpu.addWithCarry(b.get, b.set)
+    cpu.add_with_carry(b.get, b.set)
     # overflow for a
     assert_default_registers(cpu, a=0xEF, bc=None, f=None)
     assert_default_flags(cpu, zFlag=False, cFlag=True, hFlag=False)
@@ -838,7 +838,7 @@
     cpu.reset()
     a.set(0x0F)
     b.set(0x01)
-    cpu.addWithCarry(b.get, b.set)
+    cpu.add_with_carry(b.get, b.set)
     assert_default_registers(cpu, a=0x10, f=None, bc=None)
     assert_default_flags(cpu, zFlag=False, cFlag=False, hFlag=True)
     
@@ -901,7 +901,7 @@
     cpu.reset()
     a.set(value)
     b.set(value)
-    cpu.subtractWithCarry(b.get, b.set)
+    cpu.subtract_with_carry(b.get, b.set)
     assert_default_registers(cpu, a=0, bc=None, f=None)
     assert_default_flags(cpu, zFlag=True, cFlag=False, hFlag=False, nFlag=True)
     
@@ -909,14 +909,14 @@
     a.set(value)
     b.set(value-1)
     cpu.f.cFlag = True
-    cpu.subtractWithCarry(b.get, b.set)
+    cpu.subtract_with_carry(b.get, b.set)
     assert_default_registers(cpu, a=0, bc=None, f=None)
     assert_default_flags(cpu, zFlag=True, cFlag=False, hFlag=False, nFlag=True)
     
     cpu.reset()
     a.set(0x20)
     b.set(0x01)
-    cpu.subtractWithCarry(b.get, b.set)
+    cpu.subtract_with_carry(b.get, b.set)
     # overflow for a
     assert_default_registers(cpu, a=0x1F, bc=None, f=None)
     assert_default_flags(cpu, zFlag=False, cFlag=False, hFlag=True, nFlag=True)
@@ -1080,19 +1080,19 @@
     value = 0x12
     cpu.a.set(value)
     cpu.b.set(value)
-    cpu.compareA(cpu.b.get, cpu.b.set)
+    cpu.compare_a(cpu.b.get, cpu.b.set)
     assert_default_flags(cpu, zFlag=True, nFlag=True)
     
     cpu.reset()
     cpu.a.set(value)
     cpu.b.set(0)
-    cpu.compareA(cpu.b.get, cpu.b.set)
+    cpu.compare_a(cpu.b.get, cpu.b.set)
     assert_default_flags(cpu, zFlag=False, nFlag=True)
     
     cpu.reset()
     cpu.a.set(0xF0)
     cpu.b.set(0x01)
-    cpu.compareA(cpu.b.get, cpu.b.set)
+    cpu.compare_a(cpu.b.get, cpu.b.set)
     assert_default_flags(cpu, zFlag=False, hFlag=True, nFlag=True)
     
                          
@@ -1250,16 +1250,16 @@
     cpu = get_cpu()
     cpu.halted = True
     cpu.cycles = 0xFF
-    cpu.handlePendingInterrupt()
+    cpu.handle_pending_interrupt()
     assert cpu.cycles == 0
     
     cpu.reset()
     cpu.halted = True
-    cpu.interrupt.setInterruptEnable()
-    cpu.interrupt.vBlank.setPending()
-    assert cpu.interrupt.isPending() == True
+    cpu.interrupt.set_interrupt_enable()
+    cpu.interrupt.vBlank.set_pending()
+    assert cpu.interrupt.is_pending() == True
     cpu.cycles = 4
-    cpu.handlePendingInterrupt()
+    cpu.handle_pending_interrupt()
     assert cpu.cycles == 0
     assert cpu.halted == False
     
@@ -1269,12 +1269,12 @@
     cpu.pc.set(0x1234)
     cpu.sp.set(0x02)
     sp = cpu.sp.get()
-    cpu.interrupt.setInterruptEnable()
-    cpu.interrupt.vBlank.setPending()
-    cpu.interrupt.lcd.setPending()
-    assert cpu.interrupt.isPending() == True
+    cpu.interrupt.set_interrupt_enable()
+    cpu.interrupt.vBlank.set_pending()
+    cpu.interrupt.lcd.set_pending()
+    assert cpu.interrupt.is_pending() == True
     cpu.cycles = 0
-    cpu.handlePendingInterrupt()
+    cpu.handle_pending_interrupt()
     assert cpu.cycles == 0
     assert cpu.halted == False 
     assert_default_registers(cpu, pc=cpu.interrupt.vBlank.callCode, sp=sp-2)
@@ -1371,15 +1371,15 @@
     cpu.ime = True
     cpu.halted = False
     prepare_for_fetch(cpu, 0x00)  # nop 1 cycle
-    cpu.interrupt.vBlank.setPending()
-    cpu.interrupt.serial.setPending()
-    cpu.interrupt.setInterruptEnable(True)
-    assert cpu.interrupt.isPending() == True
+    cpu.interrupt.vBlank.set_pending()
+    cpu.interrupt.serial.set_pending()
+    cpu.interrupt.set_interrupt_enable(True)
+    assert cpu.interrupt.is_pending() == True
     assert cpu.halted == False
     assert cpu.ime == True  
     cycle_test(cpu, 0xFB, 1+1)
-    assert cpu.interrupt.isPending() == False
-    assert cpu.interrupt.vBlank.isPending() == False
+    assert cpu.interrupt.is_pending() == False
+    assert cpu.interrupt.vBlank.is_pending() == False
     assert cpu.pc.get() == cpu.interrupt.vBlank.callCode
     assert cpu.ime == False
 
@@ -1538,13 +1538,13 @@
     cpu = get_cpu()
     a = cpu.a
     a.set(0x01)
-    cpu.rotateLeftA()
+    cpu.rotate_left_a()
     assert_default_flags(cpu, zFlag=False, cFlag=False)
     assert_default_registers(cpu, a=0x02, f=None)
     
     cpu.reset()
     a.set(0x40)
-    cpu.rotateLeftA()
+    cpu.rotate_left_a()
     assert_default_flags(cpu, zFlag=False, cFlag=True)
     assert_default_registers(cpu, a=0x80, f=None)
     

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_interrupt.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_interrupt.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_interrupt.py	Thu May  8 13:54:14 2008
@@ -10,20 +10,20 @@
 def test_reset():
     interrupt = get_interrupt()
     assert interrupt.enable == 0
-    assert interrupt.getInterruptFlag()  == 0xE0 | constants.VBLANK
+    assert interrupt.get_interrupt_flag()  == 0xE0 | constants.VBLANK
     interrupt.enable = 1
     interrupt.flag = ~constants.VBLANK
     interrupt.reset()
     assert interrupt.enable == 0
-    assert interrupt.getInterruptFlag()  == 0xE0 | constants.VBLANK
+    assert interrupt.get_interrupt_flag()  == 0xE0 | constants.VBLANK
     
     
 def test_is_pending():
     interrupt = get_interrupt()
-    assert interrupt.isPending() == False
-    assert interrupt.isPending(0x00) == False
-    interrupt.setInterruptEnable(True)
-    assert interrupt.isPending()
+    assert interrupt.is_pending() == False
+    assert interrupt.is_pending(0x00) == False
+    interrupt.set_interrupt_enable(True)
+    assert interrupt.is_pending()
     
     
 def test_is_pending_common_masks():
@@ -31,23 +31,23 @@
     for flag in interrupt.interruptFlags:
         interrupt.reset()
         interrupt.enable = True
-        assert interrupt.vBlank.isPending()
-        flag.setPending(True)
-        assert interrupt.isPending(flag.mask)
+        assert interrupt.vBlank.is_pending()
+        flag.set_pending(True)
+        assert interrupt.is_pending(flag.mask)
         
     
 def test_raise_lower_interrupt():
     interrupt = get_interrupt()
     masks= [constants.LCD, constants.TIMER, 
             constants.JOYPAD, constants.SERIAL]
-    interrupt.setInterruptEnable(True)
-    interrupt.vBlank.setPending(True)
+    interrupt.set_interrupt_enable(True)
+    interrupt.vBlank.set_pending(True)
     for mask in masks:
-        interrupt.raiseInterrupt(mask)
-        assert interrupt.maskMapping[mask].isPending() == True
-        assert interrupt.isPending(mask) == True
+        interrupt.raise_interrupt(mask)
+        assert interrupt.maskMapping[mask].is_pending() == True
+        assert interrupt.is_pending(mask) == True
         interrupt.lower(mask)
-        assert interrupt.isPending(mask) == False
+        assert interrupt.is_pending(mask) == False
     
 def test_read_write():
     interrupt = get_interrupt()
@@ -59,5 +59,5 @@
     interrupt.reset()
     value = constants.LCD
     interrupt.write(constants.IF, value)
-    assert interrupt.getInterruptFlag() == 0xE0 | value
+    assert interrupt.get_interrupt_flag() == 0xE0 | value
     assert interrupt.read(constants.IF) == 0xE0 | value

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_joypad.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_joypad.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_joypad.py	Thu May  8 13:54:14 2008
@@ -48,7 +48,7 @@
     button = Button(value)
     assert button.oppositeButton == None
     assert button.codeValue == value
-    assert button.isPressed() == False
+    assert button.is_pressed() == False
     
     button2 = Button(value, button)
     assert button2.oppositeButton == button
@@ -56,36 +56,36 @@
     
 def test_getCode():
     button = get_button()
-    assert button.getCode() == 0
+    assert button.get_code() == 0
     button.press()
-    assert button.getCode() == button.codeValue
+    assert button.get_code() == button.codeValue
     
 def test_press_release():
     button = get_button()
     button2 = get_button()
     button.oppositeButton = button2;
     button2.press()
-    assert button2.isPressed() == True
+    assert button2.is_pressed() == True
     button.press()
-    assert button.isPressed() == True
-    assert button2.isPressed() == False
+    assert button.is_pressed() == True
+    assert button2.is_pressed() == False
     button.release()
-    assert button.isPressed() == False
-    assert button2.isPressed() == False
+    assert button.is_pressed() == False
+    assert button2.is_pressed() == False
 
 # TEST JOYPAD DRIVER -----------------------------------------------------------
 
 def test_ini():
     driver = get_driver()
     assert driver.raised == False
-    assert driver.getButtonCode() == 0
-    assert driver.getDirectionCode() == 0
+    assert driver.get_button_code() == 0
+    assert driver.get_direction_code() == 0
     
 def test_isRaised():
     driver = get_driver()
     driver.raised = True
     assert driver.raised == True
-    assert driver.isRaised() == True
+    assert driver.is_raised() == True
     assert driver.raised == False
     
 def test_button_code_values():
@@ -102,10 +102,10 @@
     
 def test_toggle_opposite_directions():
     driver = get_driver()
-    directions = [(driver.buttonUp, driver.up, driver.down),
-                 (driver.buttonDown, driver.down, driver.up),
-                 (driver.buttonLeft, driver.left, driver.right),
-                 (driver.buttonRight, driver.right, driver.left)]
+    directions = [(driver.button_up, driver.up, driver.down),
+                 (driver.button_down, driver.down, driver.up),
+                 (driver.button_left, driver.left, driver.right),
+                 (driver.button_right, driver.right, driver.left)]
     for dir in directions:
         toggleFunction = dir[0]
         button = dir[1]
@@ -114,70 +114,70 @@
         
         oppositeButton.press()
         assert driver.raised == False
-        assert button.isPressed() == False
-        assert oppositeButton.isPressed() == True
-        assert driver.getDirectionCode() == oppositeButton.codeValue
-        assert driver.getButtonCode() == 0
+        assert button.is_pressed() == False
+        assert oppositeButton.is_pressed() == True
+        assert driver.get_direction_code() == oppositeButton.codeValue
+        assert driver.get_button_code() == 0
         
         toggleFunction()
         assert driver.raised == True
-        assert button.isPressed() == True
-        assert oppositeButton.isPressed() == False
-        assert driver.getDirectionCode() == button.codeValue
-        assert driver.getButtonCode() == 0
+        assert button.is_pressed() == True
+        assert oppositeButton.is_pressed() == False
+        assert driver.get_direction_code() == button.codeValue
+        assert driver.get_button_code() == 0
         
         toggleFunction(False)
-        assert button.isPressed() == False
-        assert oppositeButton.isPressed() == False
-        assert driver.getDirectionCode() == 0
-        assert driver.getButtonCode() == 0
+        assert button.is_pressed() == False
+        assert oppositeButton.is_pressed() == False
+        assert driver.get_direction_code() == 0
+        assert driver.get_button_code() == 0
     
     
 def test_toggle_buttons():
     driver = get_driver()
-    buttons = [(driver.buttonSelect, driver.select),
-                 (driver.buttonStart, driver.start),
-                 (driver.buttonA, driver.a),
-                 (driver.buttonB, driver.b)]
+    buttons = [(driver.button_select, driver.select),
+                 (driver.button_start, driver.start),
+                 (driver.button_a, driver.a),
+                 (driver.button_b, driver.b)]
     for button in buttons:
         toggleFunction = button[0]
         button = button[1]
         driver.reset()
         
-        assert button.isPressed() == False
-        assert driver.getButtonCode() == 0
-        assert driver.getDirectionCode() == 0
+        assert button.is_pressed() == False
+        assert driver.get_button_code() == 0
+        assert driver.get_direction_code() == 0
         
         toggleFunction()
         assert driver.raised == True
-        assert button.isPressed() == True
-        assert driver.getButtonCode() == button.codeValue
-        assert driver.getDirectionCode() == 0
+        assert button.is_pressed() == True
+        assert driver.get_button_code() == button.codeValue
+        assert driver.get_direction_code() == 0
         
         toggleFunction(False)
-        assert button.isPressed() == False
-        assert driver.getButtonCode() == 0
-        assert driver.getDirectionCode() == 0
+        assert button.is_pressed() == False
+        assert driver.get_button_code() == 0
+        assert driver.get_direction_code() == 0
         
         
 def test_toggle_multiple_buttons():
     driver = get_driver()
-    buttons = [(driver.buttonSelect, driver.select),
-                 (driver.buttonStart, driver.start),
-                 (driver.buttonA, driver.a),
-                 (driver.buttonB, driver.b)]
-    toggle_multiple_test(driver, driver.getButtonCode, buttons)
+    buttons = [(driver.button_select, driver.select),
+                 (driver.button_start, driver.start),
+                 (driver.button_a, driver.a),
+                 (driver.button_b, driver.b)]
+    toggle_multiple_test(driver, driver.get_button_code, buttons)
     
 def test_toggle_mutliple_directions():
     """ 
     only testing non-opposite buttons, since they would exclude each other
     """
     driver = get_driver()
-    directions = [(driver.buttonUp, driver.up),
-                 #(driver.buttonDown, driver.down),
-                 #(driver.buttonLeft, driver.left),
-                 (driver.buttonRight, driver.right)]
-    toggle_multiple_test(driver, driver.getDirectionCode, directions)
+    directions = [(driver.button_up, driver.up),
+                 #(driver.button_down, driver.down),
+                 #(driver.button_left, driver.left),
+                 (driver.button_right, driver.right)]
+    toggle_multiple_test(driver, driver.get_direction_code, directions)
     
 def toggle_multiple_test(driver, codeGetter, buttons):
     size = len(buttons)
@@ -190,7 +190,7 @@
                 code |= buttons[j][1].codeValue
             else:
                 buttons[j][0](False)
-            assert buttons[j][1].isPressed() == toggled[j]
+            assert buttons[j][1].is_pressed() == toggled[j]
         assert codeGetter() == code
                 
 
@@ -246,10 +246,10 @@
     
 def test_update():
     joypad = get_joypad()
-    joypad.driver.buttonSelect()
-    assert joypad.driver.getButtonCode() == constants.BUTTON_SELECT
-    joypad.driver.buttonUp()
-    assert joypad.driver.getDirectionCode() == constants.BUTTON_UP
+    joypad.driver.button_select()
+    assert joypad.driver.get_button_code() == constants.BUTTON_SELECT
+    joypad.driver.button_up()
+    assert joypad.driver.get_direction_code() == constants.BUTTON_UP
     assert joypad.buttonCode == 0xF
     joypad.joyp = 0x1
     joypad.update()

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_register.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_register.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_register.py	Thu May  8 13:54:14 2008
@@ -19,7 +19,7 @@
 def get_cpu(new=False):
     if new:
         cpu = CPU(Interrupt(), Memory())
-        cpu.setROM([0]*0xFFFF);
+        cpu.set_rom([0]*0xFFFF);
         return cpu
     global TEST_CPU
     if TEST_CPU == None:
@@ -65,8 +65,8 @@
     cpu = get_cpu()
     register = DoubleRegister(cpu)
     assert register.get() == 0
-    assert register.getHi() == 0
-    assert register.getLo() == 0
+    assert register.get_hi() == 0
+    assert register.get_lo() == 0
     value = 0x1234
     reg1 = Register(cpu)
     reg1.set(0x12)
@@ -75,8 +75,8 @@
     register = DoubleRegister(cpu, reg1, reg2)
     assert register.hi == reg1
     assert register.lo == reg2
-    assert register.getHi() == reg1.get()
-    assert register.getLo() == reg2.get()
+    assert register.get_hi() == reg1.get()
+    assert register.get_lo() == reg2.get()
     
 def test_double_register():
     register = DoubleRegister(get_cpu())
@@ -102,23 +102,23 @@
     oldCycles = register.cpu.cycles
     register.set(valueHi, valueLo)
     assert oldCycles-register.cpu.cycles == 2
-    assert register.getHi() == valueHi
-    assert register.getLo() == valueLo
+    assert register.get_hi() == valueHi
+    assert register.get_lo() == valueLo
     assert register.get() == value
     
     valueHi = 0x56
     oldCycles = register.cpu.cycles
-    register.setHi(valueHi)
+    register.set_hi(valueHi)
     assert oldCycles-register.cpu.cycles == 1
-    assert register.getHi() == valueHi
-    assert register.getLo() == valueLo
+    assert register.get_hi() == valueHi
+    assert register.get_lo() == valueLo
     
     valueLo = 0x78
     oldCycles = register.cpu.cycles
-    register.setLo(valueLo)
+    register.set_lo(valueLo)
     assert oldCycles-register.cpu.cycles == 1
-    assert register.getHi() == valueHi
-    assert register.getLo() == valueLo
+    assert register.get_hi() == valueHi
+    assert register.get_lo() == valueLo
     
     
 def test_double_register_methods():

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	Thu May  8 13:54:14 2008
@@ -15,7 +15,7 @@
 def test_rom1():
     gameBoy = GameBoy()
     try:
-        gameBoy.loadCartridgeFile(ROM_PATH+"/rom1/rom1.raw")
+        gameBoy.load_cartridge_file(ROM_PATH+"/rom1/rom1.raw")
         py.test.fail()
     except:
         pass
@@ -24,7 +24,7 @@
 def test_rom2():
     gameBoy = GameBoy()
     try:
-        gameBoy.loadCartridgeFile(ROM_PATH+"/rom2/rom2.raw")
+        gameBoy.load_cartridge_file(ROM_PATH+"/rom2/rom2.raw")
         py.test.fail()
     except:
         pass
@@ -33,13 +33,13 @@
 def test_rom3():
     """ some NOP and an endless loop at the end '"""
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom3/rom3.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom3/rom3.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     
     
 def test_rom4():
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom4/rom4.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom4/rom4.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     
     assert gameBoy.cpu.ime     == False
@@ -49,7 +49,7 @@
     
 def test_rom5():
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom5/rom5.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom5/rom5.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     # stop test
     assert gameBoy.cpu.a.get() != 0xFF
@@ -57,24 +57,24 @@
     
 def test_rom6():
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom6/rom6.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom6/rom6.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     
     
 def test_rom7():
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom7/rom7.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom7/rom7.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     
     
 def test_rom8():
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom8/rom8.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom8/rom8.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     
     
 def test_rom9():
     gameBoy = GameBoy()
-    gameBoy.loadCartridgeFile(ROM_PATH+"/rom9/rom9.gb")
+    gameBoy.load_cartridge_file(ROM_PATH+"/rom9/rom9.gb")
     gameBoy.emulate(EMULATION_CYCLES)
     

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py	Thu May  8 13:54:14 2008
@@ -18,11 +18,11 @@
     assert serial.sc == 0
     
     
-def test_setSerialControl():
+def test_set_serial_control():
     serial = get_serial()
     value = 0x12
-    serial.setSerialControl(value)
-    assert serial.getSerialControl() == value
+    serial.set_serial_control(value)
+    assert serial.get_serial_control() == value
     assert serial.cycles == constants.SERIAL_IDLE_CLOCK + constants.SERIAL_CLOCK
     
     
@@ -43,7 +43,7 @@
     assert cycles-serial.cycles == 2
     assert serial.sb == 0
     assert serial.sc == 0x81
-    assert serial.interrupt.serial.isPending() == False
+    assert serial.interrupt.serial.is_pending() == False
     
     serial.reset()
     serial.sc = 0x81
@@ -52,7 +52,7 @@
     assert serial.sb == 0xFF
     assert serial.sc == 0x81 & 0x7F
     assert serial.cycles == constants.SERIAL_IDLE_CLOCK
-    assert serial.interrupt.serial.isPending() == True
+    assert serial.interrupt.serial.is_pending() == True
     
     
 def test_read_write():
@@ -67,4 +67,5 @@
     assert serial.read(constants.SC) == value
     assert serial.sc == value
     
-    assert serial.read(0) == 0xFF
\ No newline at end of file
+    assert serial.read(0) == 0xFF
+    
\ No newline at end of file

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py	Thu May  8 13:54:14 2008
@@ -28,32 +28,32 @@
     timer.div = 10
     value = 0x11
     timer.write(constants.DIV, value)
-    assert timer.getDivider() == 0
+    assert timer.get_divider() == 0
     assert timer.read(constants.DIV) == 0
     
     timer.reset()
     timer.write(constants.TIMA, value)
-    assert timer.getTimerCounter() == value
+    assert timer.get_timer_counter() == value
     assert timer.read(constants.TIMA) == value
     timer.reset()
     
     timer.write(constants.TMA, value)
-    assert timer.getTimerModulo() == value
+    assert timer.get_timer_modulo() == value
     assert timer.read(constants.TMA) == value
     timer.reset()
     
     
-def test_getTimerControl():
+def test_get_timer_control():
     timer = get_timer()
     value = 0x12
     timer.write(constants.TAC, value)
-    assert timer.getTimerControl() == 0xF8 | value 
+    assert timer.get_timer_control() == 0xF8 | value 
     assert timer.read(constants.TAC) == 0xF8 |value
 
-def test_setTimerControl():
+def test_set_timer_control():
     timer = get_timer()
     value = 0x12
-    timer.setTimerControl(value)
+    timer.set_timer_control(value)
     assert timer.tac == value
     assert timer.timerCycles == constants.TIMER_CLOCK[value & 0x03]
     assert timer.timerClock  == constants.TIMER_CLOCK[value & 0x03]
@@ -61,7 +61,7 @@
     timer.tac = value+1
     timer.timerClock = 0
     timer.timerCycles = 0
-    timer.setTimerControl(value+1)
+    timer.set_timer_control(value+1)
     assert timer.tac == value+1
     assert timer.timerClock == 0
     assert timer.timerClock == 0
@@ -70,66 +70,66 @@
     timer = get_timer()
     value = 0x12
     timer.div = value
-    assert timer.getDivider() == timer.div
+    assert timer.get_divider() == timer.div
     # divider resets on write
-    timer.setDivider(value)
-    assert timer.getDivider() == 0
+    timer.set_divider(value)
+    assert timer.get_divider() == 0
     
 def test_cycles():
     timer = get_timer()
     value = 10
     timer.dividerCycles = value
-    assert timer.getCycles() == timer.dividerCycles
+    assert timer.get_cycles() == timer.dividerCycles
     timer.tac = 0x04
     timer.timerCycles = value-1
     timer.timerCycles = value
-    assert timer.getCycles() == timer.timerCycles
+    assert timer.get_cycles() == timer.timerCycles
     
 def test_emulateDivider_normal():
     timer = get_timer()
     value = 2
     timer.timerCycles = 0
-    timer.emulateTimer(value)
+    timer.emulate_timer(value)
     
 def test_test_emulateDivider_zero():
     timer = get_timer()
     value = 2
     timer.timerCycles = value
-    timer.emulateTimer(value)
+    timer.emulate_timer(value)
     assert timer.timerCycles == value
     
-def test_emulateTimer_tac_return():
+def test_emulate_timer_tac_return():
     timer = get_timer()
     timer.tac = 0
     timer.timerCycles = -10
     cycles = timer.timerCycles
-    timer.emulateTimer(10)
+    timer.emulate_timer(10)
     assert timer.timerCycles == cycles
     
-def test_emulateTimer_timer_cycles_return():
+def test_emulate_timer_timer_cycles_return():
     timer = get_timer()
     timer.tac = 0x04
     value = 10
     timer.timerCycles = value+1
     cycles = timer.timerCycles
-    timer.emulateTimer(value)
+    timer.emulate_timer(value)
     assert timer.timerCycles == 1
     
     timer = get_timer()
     timer.tac = 0x04
     
     
-def test_emulateTimer_interrupt():
+def test_emulate_timer_interrupt():
     timer = get_timer()
     ticks = 0
     timer.tac = 0x04
     timer.tima = -1
     # raise an interupt as we pass 0
-    assert timer.interrupt.isPending(constants.TIMER) == False
+    assert timer.interrupt.is_pending(constants.TIMER) == False
     timer.timerCycles = -timer.timerClock+1
-    timer.emulateTimer(ticks)
+    timer.emulate_timer(ticks)
     assert timer.timerCycles == 1
     assert timer.tima == timer.tma
-    assert timer.interrupt.timer.isPending()
+    assert timer.interrupt.timer.is_pending()
     
     
\ No newline at end of file

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py	Thu May  8 13:54:14 2008
@@ -3,6 +3,7 @@
  
 Timer and Divider
 """
+
 from pypy.lang.gameboy import constants
 from math import ceil
 
@@ -20,61 +21,61 @@
 
     def write(self,  address, data):
         if address==constants.DIV:
-            self.setDivider(data)
+            self.set_divider(data)
         elif address==constants.TIMA:
-            self.setTimerCounter(data)
+            self.set_timer_counter(data)
         elif address==constants.TMA:
-            self.setTimerModulo(data)
+            self.set_timer_modulo(data)
         elif address==constants.TAC:
-            self.setTimerControl(data)
+            self.set_timer_control(data)
     
     def read(self,  address):
         if address==constants.DIV:
-            return self.getDivider()
+            return self.get_divider()
         elif address==constants.TIMA:
-            return self.getTimerCounter()
+            return self.get_timer_counter()
         elif address==constants.TMA:
-            return self.getTimerModulo()
+            return self.get_timer_modulo()
         elif address==constants.TAC:
-            return self.getTimerControl()
+            return self.get_timer_control()
         return 0xFF
 
-    def getDivider(self):
+    def get_divider(self):
         return self.div
     
-    def setDivider(self,  data): #DIV register resets on write
+    def set_divider(self,  data): #DIV register resets on write
         self.div = 0
 
-    def getTimerCounter(self):
+    def get_timer_counter(self):
         return self.tima
     
-    def setTimerCounter(self,  data):
+    def set_timer_counter(self,  data):
         self.tima = data
 
-    def getTimerModulo(self):
+    def get_timer_modulo(self):
         return self.tma
     
-    def setTimerModulo(self,  data):
+    def set_timer_modulo(self,  data):
         self.tma = data
 
-    def getTimerControl(self):
+    def get_timer_control(self):
         return 0xF8 | self.tac
 
-    def setTimerControl(self,  data):
+    def set_timer_control(self,  data):
         if ((self.tac & 0x03) != (data & 0x03)):
             self.timerClock =  self.timerCycles = constants.TIMER_CLOCK[data & 0x03]
         self.tac = data
 
-    def getCycles(self):
+    def get_cycles(self):
         if (self.tac & 0x04) != 0 and self.timerCycles < self.dividerCycles:
                 return self.timerCycles
         return self.dividerCycles
 
     def emulate(self,  ticks):
-        self.emulateDivider(ticks)
-        self.emulateTimer(ticks)
+        self.emulate_divider(ticks)
+        self.emulate_timer(ticks)
 
-    def emulateDivider(self,  ticks):
+    def emulate_divider(self,  ticks):
         self.dividerCycles -= ticks
         if self.dividerCycles > 0:
             return
@@ -82,23 +83,23 @@
         self.div = (self.div + count) & 0xFF
         self.dividerCycles += constants.DIV_CLOCK*count
             
-    def emulateTimer(self,  ticks):
+    def emulate_timer(self,  ticks):
         if (self.tac & 0x04) == 0:
             return
         self.timerCycles -= ticks
         if self.timerCycles > 0:
             return
         count = int(ceil(-1.0*self.timerCycles / self.timerClock))
-        self.timaZeroPassCheck(count)
+        self.tima_tero_pass_check(count)
         self.tima = (self.tima + count) & 0xFF
         self.timerCycles += self.timerClock * count
 
-    def timaZeroPassCheck(self, count):
+    def tima_tero_pass_check(self, count):
         if (self.tima < 0) and (self.tima + count >= 0):
             self.tima = self.tma - count
             print "raising"
-            self.interrupt.raiseInterrupt(constants.TIMER)
-            print self.interrupt.timer.isPending(), self.interrupt.isPending(constants.TIMER)
+            self.interrupt.raise_interrupt(constants.TIMER)
+            print self.interrupt.timer.is_pending(), self.interrupt.is_pending(constants.TIMER)
         
 # CLOCK DRIVER -----------------------------------------------------------------
 
@@ -107,6 +108,6 @@
     def __init__(self):
         pass
     
-    def getTime(self):
+    def get_time(self):
         return System.currentTimeMillis() / 1000
         

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	Thu May  8 13:54:14 2008
@@ -15,17 +15,16 @@
     #objects = []#= new int[OBJECTS_PER_LINE]
     #palette = []#= new int[1024]
 
-
     def __init__(self, videoDriver, interrupt, memory):
         self.driver = videoDriver
         self.interrupt = interrupt
         self.memory = memory
         self.reset()
 
-    def getFrameSkip(self):
+    def get_frame_skip(self):
         return self.frameSkip
 
-    def setFrameSkip(self, frameSkip):
+    def set_frame_skip(self, frameSkip):
         self.frameSkip = frameSkip
 
     def reset(self):
@@ -61,213 +60,217 @@
     def write(self, address, data):
         # assert data >= 0x00 and data <= 0xFF
         if address == constants.LCDC :
-            self.setControl(data)
+            self.set_control(data)
         elif address == constants.STAT:
-            self.setStatus(data)
+            self.set_status(data)
         elif address == constants.SCY:
-            self.setScrollY(data)
+            self.set_scroll_y(data)
         elif address == constants.SCX:
-            self.setScrollX(data)
+            self.set_scroll_x(data)
         elif address == constants.LY:
             # Read OnlineY
             pass
         elif address == constants.LYC:
-            self.setLYCompare(data)
+            self.set_ly_compare(data)
         elif address == constants.DMA:
-            self.setDMA(data)
+            self.set_dma(data)
         elif address == constants.BGP:
-            self.setBackgroundPalette(data)
+            self.set_background_palette(data)
         elif address == constants.OBP0:
-            self.setObjectPalette0(data)
+            self.set_object_palette_0(data)
         elif address == constants.OBP1:
-            self.setObjectPalette1(data)
+            self.set_object_palette_1(data)
         elif address == constants.WY:
-            self.setWindowY(data)
+            self.set_window_y(data)
         elif address == constants.WX:
-            self.setWindowX(data)
+            self.set_window_x(data)
         else:
-            self.writeOAM(address, data)
+            self.write_oam(address, data)
 
-    def writeOAM(self, address, data):
-        if (address >= constants.OAM_ADDR and address < constants.OAM_ADDR + constants.OAM_SIZE):
+    def write_oam(self, address, data):
+        if address >= constants.OAM_ADDR and \
+           address < constants.OAM_ADDR + constants.OAM_SIZE:
             self.oam[address - constants.OAM_ADDR] = data & 0xFF
-        elif (address >= constants.VRAM_ADDR and address < constants.VRAM_ADDR + constants.VRAM_SIZE):
-            self.vram[address - constants.VRAM_ADDR] = data & 0xFF
+        elif address >= constants.VRAM_ADDR and \
+             address < constants.VRAM_ADDR + constants.VRAM_SIZE:
+              self.vram[address - constants.VRAM_ADDR] = data & 0xFF
             
     def read(self, address):
         if address == constants.LCDC:
-            return self.getControl()
+            return self.get_control()
         elif address == constants.STAT:
-            return self.getStatus()
+            return self.get_status()
         elif address == constants.SCY:
-            return self.getScrollY()
+            return self.get_scroll_y()
         elif address == constants.SCX:
-            return self.getScrollX()
+            return self.get_scroll_x()
         elif address == constants.LY:
-            return self.getLineY()
+            return self.get_line_y()
         elif address == constants.LYC:
-            return self.getLineYCompare()
+            return self.get_line_y_compare()
         elif address == constants.DMA:
-            return self.getDMA()
+            return self.get_dma()
         elif address == constants.BGP:
-            return self.getBackgroundPalette()
+            return self.get_background_palette()
         elif address == constants.OBP0:
-            return self.getObjectPalette0()
+            return self.get_object_palette_0()
         elif address == constants.OBP1:
-            return self.getObjectPalette1()
+            return self.get_object_palette_1()
         elif address == constants.WY:
-            return self.getWindowY()
+            return self.get_window_y()
         elif address == constants.WX:
-            return self.getWindowX()
+            return self.get_window_x()
         else:
-            return self.readOAM(address)
-        
+            return self.read_oam(address)
         
-    def readOAM(self, address):
-        if (address >= constants.OAM_ADDR and address < constants.OAM_ADDR + constants.OAM_SIZE):
-            return self.oam[address - constants.OAM_ADDR]
-        elif (address >= constants.VRAM_ADDR and address < constants.VRAM_ADDR + constants.VRAM_SIZE):
-            return self.vram[address - constants.VRAM_ADDR]
+    def read_oam(self, address):
+        if (address >= constants.OAM_ADDR and \
+            address < constants.OAM_ADDR + constants.OAM_SIZE):
+             return self.oam[address - constants.OAM_ADDR]
+        elif (address >= constants.VRAM_ADDR and \
+            address < constants.VRAM_ADDR + constants.VRAM_SIZE):
+             return self.vram[address - constants.VRAM_ADDR]
         return 0xFF
 
-    def getCycles(self):
+    def get_cycles(self):
         return self.cycles
 
     def emulate(self, ticks):
         if (self.control & 0x80) != 0:
             self.cycles -= ticks
-            self.consumeCycles()
+            self.consume_cycles()
             
-    def consumeCycles(self):
-        while (self.cycles <= 0):
+    def consume_cycles(self):
+        while self.cycles <= 0:
             if self.stat == 0:
-                self.emulateHBlank()
+                self.emulate_hblank()
             elif self.stat == 1:
-                self.emulateVBlank()
+                self.emulate_vblank()
             elif self.stat == 2:
-                self.emulateOAM()
+                self.emulate_oam()
             else:
-                self.emulateTransfer()
+                self.emulate_transfer()
 
-    def getControl(self):
+    def get_control(self):
         return self.control
 
-    def setControl(self, data):
+    def set_control(self, data):
         if (self.control & 0x80) != (data & 0x80):
-            self.resetControl(data)
+            self.reset_control(data)
         # don't draw window if it was not enabled and not being drawn before
-        if ((self.control & 0x20) == 0 and (data & 0x20) != 0 and self.wlineY == 0 and self.lineY > self.windowY):
-            self.wlineY = 144
+        if (self.control & 0x20) == 0 and (data & 0x20) != 0 and \
+           self.wlineY == 0 and self.lineY > self.windowY:
+             self.wlineY = 144
         self.control = data
 
-    def resetControl(self, data):
-            # NOTE: do not reset constants.LY=LYC flag (bit 2) of the STAT register (Mr. Do!)
-            if (data & 0x80) != 0:
-                self.stat = (self.stat & 0xFC) | 0x02
-                self.cycles = constants.MODE_2_TICKS
-                self.lineY = 0
-                self.display = False
-            else:
-                self.stat = (self.stat & 0xFC) | 0x00
-                self.cycles = constants.MODE_1_TICKS
-                self.lineY = 0
-                self.clearFrame()
+    def reset_control(self, data):
+        # NOTE: do not reset constants.LY=LYC flag (bit 2) of the STAT register (Mr. Do!)
+        if (data & 0x80) != 0:
+            self.stat = (self.stat & 0xFC) | 0x02
+            self.cycles = constants.MODE_2_TICKS
+            self.lineY = 0
+            self.display = False
+        else:
+            self.stat = (self.stat & 0xFC) | 0x00
+            self.cycles = constants.MODE_1_TICKS
+            self.lineY = 0
+            self.clear_frame()
                 
-    def getStatus(self):
+    def get_status(self):
         return 0x80 | self.stat
 
-    def setStatus(self, data):
+    def set_status(self, data):
         self.stat = (self.stat & 0x87) | (data & 0x78)
         # Gameboy Bug
-        if ((self.control & 0x80) != 0 and (self.stat & 0x03) == 0x01 and (self.stat & 0x44) != 0x44):
-            self.interrupt.raiseInterrupt(constants.LCD)
+        if (self.control & 0x80) != 0 and (self.stat & 0x03) == 0x01 and \
+           (self.stat & 0x44) != 0x44:
+             self.interrupt.raise_interrupt(constants.LCD)
 
-    def getScrollY(self):
+    def get_scroll_y(self):
         return self.scrollY
                 
-    def setScrollY(self, data):
+    def set_scroll_y(self, data):
         self.scrollY = data
         
-    def getScrollX(self):
+    def get_scroll_x(self):
         return self.scrollX
 
-    def setScrollX(self, data):
+    def set_scroll_x(self, data):
         self.scrollX = data
         
-    def getLineY(self):
+    def get_line_y(self):
         return self.lineY
 
-    def getLineYCompare(self):
+    def get_line_y_compare(self):
         return self.lineYCompare
 
-    def setLYCompare(self, data):
+    def set_ly_compare(self, data):
         self.lineYCompare = data
         if (self.control & 0x80) == 0:
             return
-        if (self.lineY == self.lineYCompare):
+        if self.lineY == self.lineYCompare:
             # NOTE: raise interrupt once per line
             if (self.stat & 0x04) == 0:
                 # constants.LYC=LY interrupt
                 self.stat |= 0x04
 #                if (self.stat & 0x40) != 0:
-                self.interrupt.raiseInterrupt(constants.LCD)
+                self.interrupt.raise_interrupt(constants.LCD)
         else:
             self.stat &= 0xFB
                 
-    def getDMA(self):
+    def get_dma(self):
         return self.dma
 
-    def setDMA(self, data):
+    def set_dma(self, data):
         self.dma = data
         for index in range(0, constants.OAM_SIZE):
             self.oam[index] = self.memory.read((self.dma << 8) + index)
 
-
-    def getBackgroundPalette(self):
+    def get_background_palette(self):
         return self.backgroundPalette
 
-    def setBackgroundPalette(self, data):
-        if (self.backgroundPalette != data):
+    def set_background_palette(self, data):
+        if self.backgroundPalette != data:
             self.backgroundPalette = data
             self.dirty = True
 
-    def getObjectPalette0(self):
+    def get_object_palette_0(self):
         return self.objectPalette0
 
-    def setObjectPalette0(self, data):
-        if (self.objectPalette0 != data):
+    def set_object_palette_0(self, data):
+        if self.objectPalette0 != data:
             self.objectPalette0 = data
             self.dirty = True
 
-    def getObjectPalette1(self):
+    def get_object_palette_1(self):
         return self.objectPalette1
 
-    def setObjectPalette1(self, data):
-        if (self.objectPalette1 != data):
+    def set_object_palette_1(self, data):
+        if self.objectPalette1 != data:
             self.objectPalette1 = data
             self.dirty = True
 
-    def getWindowY(self):
+    def get_window_y(self):
         return self.windowY
 
-    def setWindowY(self, data):
+    def set_window_y(self, data):
         self.windowY = data
         
-    def getWindowX(self):
+    def get_window_x(self):
         return self.windowX
 
-    def setWindowX(self, data):
+    def set_window_x(self, data):
         self.windowX = data
 
-    def emulateOAM(self):
+    def emulate_oam(self):
         self.stat = (self.stat & 0xFC) | 0x03
         self.cycles += constants.MODE_3_BEGIN_TICKS
         self.transfer = True
 
-    def emulateTransfer(self):
+    def emulate_transfer(self):
         if self.transfer:
-            if (self.display):
-                self.drawLine()
+            if self.display:
+                self.draw_line()
             self.stat = (self.stat & 0xFC) | 0x03
             self.cycles += constants.MODE_3_END_TICKS
             self.transfer = False
@@ -275,34 +278,34 @@
             self.stat = (self.stat & 0xFC)
             self.cycles += constants.MODE_0_TICKS
             # H-Blank interrupt
-            if ((self.stat & 0x08) != 0 and (self.stat & 0x44) != 0x44):
-                self.interrupt.raiseInterrupt(constants.LCD)
+            if (self.stat & 0x08) != 0 and (self.stat & 0x44) != 0x44:
+                self.interrupt.raise_interrupt(constants.LCD)
 
-    def emulateHBlank(self):
+    def emulate_hblank(self):
         self.lineY+=1
-        self.emulateHBlankLineYCompare()
+        self.emulate_hblank_line_y_compare()
         if self.lineY < 144:
-            self.emulateHBlankPart1()
+            self.emulate_hblank_part_1()
         else:
-            self.emulateHBlankPart2()
+            self.emulate_hblank_part_2()
             
-    def emulateHBlankLineYCompare(self):
+    def emulate_hblank_line_y_compare(self):
         if self.lineY == self.lineYCompare:
             # constants.LYC=LY interrupt
             self.stat |= 0x04
             if (self.stat & 0x40) != 0:
-                self.interrupt.raiseInterrupt(constants.LCD)
+                self.interrupt.raise_interrupt(constants.LCD)
         else:
             self.stat &= 0xFB
             
-    def emulateHBlankPart1(self):
+    def emulate_hblank_part_1(self):
         self.stat = (self.stat & 0xFC) | 0x02
         self.cycles += constants.MODE_2_TICKS
         # constants.OAM interrupt
-        if ((self.stat & 0x20) != 0 and (self.stat & 0x44) != 0x44):
-            self.interrupt.raiseInterrupt(constants.LCD)
+        if (self.stat & 0x20) != 0 and (self.stat & 0x44) != 0x44:
+            self.interrupt.raise_interrupt(constants.LCD)
         
-    def emulateHBlankPart2(self):
+    def emulate_hblank_part_2(self):
         if self.display:
             self.drawFrame()
         self.frames += 1
@@ -316,37 +319,36 @@
         self.cycles += constants.MODE_1_BEGIN_TICKS
         self.vblank = True
         
-        
-    def emulateVBlank(self):
+    def emulate_vblank(self):
         if self.vblank:
-            self.emulateVBlankVBlank()
+            self.emulate_vblank_vblank()
         elif self.lineY == 0:
-            self.emulateVBlankFirstYLine()
+            self.emulate_vblank_first_y_line()
         else:
-            self.emulateVBlankOther()
+            self.emulate_vblank_other()
 
-    def emulateVBlankVBlank(self):
+    def emulate_vblank_vblank(self):
         self.vblank = False
         self.stat = (self.stat & 0xFC) | 0x01
         self.cycles += constants.MODE_1_TICKS - constants.MODE_1_BEGIN_TICKS
         # V-Blank interrupt
-        if ((self.stat & 0x10) != 0):
-            self.interrupt.raiseInterrupt(constants.LCD)
+        if (self.stat & 0x10) != 0:
+            self.interrupt.raise_interrupt(constants.LCD)
         # V-Blank interrupt
-        self.interrupt.raiseInterrupt(constants.VBLANK)
+        self.interrupt.raise_interrupt(constants.VBLANK)
         
-    def emulateVBlankFirstYLine(self):
+    def emulate_vblank_first_y_line(self):
         self.stat = (self.stat & 0xFC) | 0x02
         self.cycles += constants.MODE_2_TICKS
         # constants.OAM interrupt
-        if ((self.stat & 0x20) != 0 and (self.stat & 0x44) != 0x44):
-            self.interrupt.raiseInterrupt(constants.LCD)
+        if (self.stat & 0x20) != 0 and (self.stat & 0x44) != 0x44:
+            self.interrupt.raise_interrupt(constants.LCD)
             
-    def emulateVBlankOther(self):
-        if (self.lineY < 153):
+    def emulate_vblank_other(self):
+        if self.lineY < 153:
             self.lineY+=1
             self.stat = (self.stat & 0xFC) | 0x01
-            if (self.lineY == 153):
+            if self.lineY == 153:
                 self.cycles += constants.MODE_1_END_TICKS
             else:
                 self.cycles += constants.MODE_1_TICKS
@@ -354,37 +356,37 @@
             self.lineY = self.wlineY = 0
             self.stat = (self.stat & 0xFC) | 0x01
             self.cycles += constants.MODE_1_TICKS - constants.MODE_1_END_TICKS
-        if (self.lineY == self.lineYCompare):
+        if self.lineY == self.lineYCompare:
             # constants.LYC=LY interrupt
             self.stat |= 0x04
-            if ((self.stat & 0x40) != 0):
-                self.interrupt.raiseInterrupt(constants.LCD)
+            if (self.stat & 0x40) != 0:
+                self.interrupt.raise_interrupt(constants.LCD)
         else:
             self.stat &= 0xFB
     
-    def drawFrame(self):
-        self.driver.updateDisplay()
+    def draw_frame(self):
+        self.driver.update_display()
 
-    def clearFrame(self):
-        self.clearPixels()
-        self.driver.updateDisplay()
+    def clear_frame(self):
+        self.clear_pixels()
+        self.driver.update_display()
 
-    def drawLine(self):
+    def draw_line(self):
         if (self.control & 0x01) != 0:
-            self.drawBackground()
+            self.draw_background()
         else:
-            self.drawCleanBackground()
+            self.draw_clean_background()
         if (self.control & 0x20) != 0:
-            self.drawWindow()
+            self.draw_window()
         if (self.control & 0x02) != 0:
-            self.drawObjects()
-        self.drawPixels()
+            self.draw_objects()
+        self.draw_pixels()
 
-    def drawCleanBackground(self):
+    def draw_clean_background(self):
         for x in range(0, 8+160+8):
             self.line[x] = 0x00
 
-    def drawBackground(self):
+    def draw_background(self):
         y = (self.scrollY + self.lineY) & 0xFF
         x = self.scrollX & 0xFF
         tileMap = constants.VRAM_MAP_A
@@ -395,10 +397,11 @@
             tileData = constants.VRAM_DATA_A
         tileMap  += ((y >> 3) << 5) + (x >> 3)
         tileData += (y & 7) << 1
-        self.drawTiles(8 - (x & 7), tileMap, tileData)
+        self.draw_tiles(8 - (x & 7), tileMap, tileData)
 
-    def drawWindow(self):
-        if (self.lineY < self.windowY or self.windowX >= 167 or self.wlineY >= 144):
+    def draw_window(self):
+        if self.lineY < self.windowY or self.windowX >= 167 or \
+           self.wlineY >= 144:
             return
         tileMap = constants.VRAM_MAP_A
         if (self.control & 0x40) != 0:
@@ -408,11 +411,11 @@
             tileData = constants.VRAM_DATA_A
         tileMap += (self.wlineY >> 3) << 5
         tileData += (self.wlineY & 7) << 1
-        self.drawTiles(self.windowX + 1, tileMap, tileData)
+        self.draw_tiles(self.windowX + 1, tileMap, tileData)
         self.wlineY+=1
 
-    def drawObjects(self):
-        count = self.scanObjects()
+    def draw_objects(self):
+        count = self.scan_objects()
         lastx = 176
         for index in range(176, count):
             data = self.objects[index]
@@ -420,12 +423,12 @@
             flags = (data >> 12) & 0xFF
             address = data & 0xFFF
             if (x + 8 <= lastx):
-                self.drawObjectTile(x, address, flags)
+                self.draw_object_tile(x, address, flags)
             else:
-                self.drawOverlappedObjectTile(x, address, flags)
+                self.draw_overlapped_object_tile(x, address, flags)
             lastx = x
 
-    def scanObjects(self):
+    def scan_objects(self):
         count = 0
         # search active objects
         for offset in range(0, 4*40, 4):
@@ -453,42 +456,44 @@
                 # Y flip
                 if ((flags & 0x40) != 0):
                     y = 7 - y
-            self.objects[count] = (x << 24) + (count << 20) + (flags << 12) + ((tile << 4) + (y << 1))
+            self.objects[count] = (x << 24) + (count << 20) + (flags << 12) + \
+                                  (tile << 4) + (y << 1)
             count += 1
             if count >= constants.OBJECTS_PER_LINE:
                 break
-        self.sortScanObject(count)
+        self.sort_scan_object(count)
         return count
 
-    def sortScanObject(self, count):
+    def sort_scan_object(self, count):
         # sort objects from lower to higher priority
         for index in range(0, count):
             rightmost = index
             for number in range(index+1, count):
-                if (self.objects[number] >> 20) > (self.objects[rightmost] >> 20):
+                if (self.objects[number] >> 20) > \
+                   (self.objects[rightmost] >> 20):
                     rightmost = number
             if rightmost != index:
                 data = self.objects[index]
                 self.objects[index] = self.objects[rightmost]
                 self.objects[rightmost] = data
 
-    def drawTiles(self, x, tileMap, tileData):
+    def draw_tiles(self, x, tileMap, tileData):
         while (x < 168):
             if (self.control & 0x10) != 0:
                 tile = self.vram[tileMap] & 0xFF
             else:
                 tile = (self.vram[tileMap] ^ 0x80) & 0xFF
-            self.drawTile(x, tileData + (tile << 4))
+            self.draw_tile(x, tileData + (tile << 4))
             tileMap = (tileMap & 0x1FE0) + ((tileMap + 1) & 0x001F)
             x += 8
             
-    def getPattern(self, address):
+    def get_pattern(self, address):
         pattern = self.vram[address]      & 0xFF
         pattern +=(self.vram[address + 1] & 0xFF) << 8
         return pattern
 
-    def drawObject(self, setter):
-        pattern = self.getPattern(address)
+    def draw_object(self, setter):
+        pattern = self.get_pattern(address)
         self.mask = 0
         # priority
         if (flags & 0x80) != 0:
@@ -497,11 +502,11 @@
         if (flags & 0x10) != 0:
             self.mask |= 0x0004
         if (flags & 0x20) != 0:
-            self.drawObjectNormal(x, pattern, mask, setter)
+            self.draw_object_normal(x, pattern, mask, setter)
         else:
-            self.drawObjectFlipped(x, pattern, mask, setter)
+            self.draw_object_flipped(x, pattern, mask, setter)
             
-    def drawObjectNormal(self, x, pattern, mask, setter):
+    def draw_object_normal(self, x, pattern, mask, setter):
         for i in range(0, 7):
             color = pattern >> (6-i)
             if (color & 0x0202) != 0:
@@ -510,7 +515,7 @@
         if (color & 0x0202) != 0:
             setter(self, x+7, color,  mask)
         
-    def drawObjectFlipped(self, x, pattern, mask, setter):
+    def draw_object_flipped(self, x, pattern, mask, setter):
         color = pattern << 1
         if (color & 0x0202) != 0:
             setter(self, x, color | mask)
@@ -519,57 +524,62 @@
             if (color & 0x0202) != 0:
                 setter(self, x + i + 1, color | mask)
             
-    def drawTile(self, x, address):
-        pattern =  self.getPattern(address)
+    def draw_tile(self, x, address):
+        pattern =  self.get_pattern(address)
         for i in range(0, 8):
             self.line[x + i] = (pattern >> (7-i)) & 0x0101
 
-    def drawObjectTile(self, x, address, flags):
-        pattern = self.getPattern(address)
-        self.drawObject(self.setTileLine)
+    def draw_object_tile(self, x, address, flags):
+        pattern = self.get_pattern(address)
+        self.draw_object(self.setTileLine)
         
-    def setTileLine(self, pos, color, mask):
+    def set_tile_line(self, pos, color, mask):
         self.line[pos] |= color | mask
 
-    def drawOverlappedObjectTile(self, x, address, flags):
-        self.drawObject(self.setOverlappedObjectLine)
+    def draw_overlapped_object_tile(self, x, address, flags):
+        self.draw_object(self.setOverlappedObjectLine)
         
-    def setOverlappedObjectLine(self, pos, color, mask):
+    def set_overlapped_object_line(self, pos, color, mask):
         self.line[pos] = (self.line[pos] & 0x0101) | color | mask
-            
 
-    def drawPixels(self):
-        self.updatePalette()
-        pixels = self.driver.getPixels()
-        offset = self.lineY * self.driver.getWidth()
+    def draw_pixels(self):
+        self.update_palette()
+        pixels = self.driver.get_pixels()
+        offset = self.lineY * self.driver.get_width()
         for x in range(8, 168, 4):
             for i in range(0,4):
                 pattern = self.line[x + i]
                 pixels[offset + i] = self.palette[pattern]
             offset += 4
 
-    def clearPixels(self):
-        self.driver.clearPixels()
+    def clear_pixels(self):
+        self.driver.clear_pixels()
 
-    def updatePalette(self):
+    def update_palette(self):
         if not self.dirty:
             return
-        # bit 4/0 = constants.BG color, bit 5/1 = constants.OBJ color, bit 2 = constants.OBJ palette, bit
-        # 3 = constants.OBJ priority
+        # bit 4/0 = constants.BG color, 
+        # bit 5/1 = constants.OBJ color, 
+        # bit 2 = constants.OBJ palette, 
+        # bit 3 = constants.OBJ priority
         for pattern in range(0, 64):
             #color
-            if ((pattern & 0x22) == 0 or ((pattern & 0x08) != 0 and (pattern & 0x11) != 0)):
+            if (pattern & 0x22) == 0 or ((pattern & 0x08) != 0 and \
+               (pattern & 0x11) != 0):
                 # constants.OBJ behind constants.BG color 1-3
-                color = (self.backgroundPalette >> ((((pattern >> 3) & 0x02) + (pattern & 0x01)) << 1)) & 0x03
+                color = (self.backgroundPalette >> ((((pattern >> 3) & 0x02) +\
+                        (pattern & 0x01)) << 1)) & 0x03
              # constants.OBJ above constants.BG
             elif ((pattern & 0x04) == 0):
-                color = (self.objectPalette0 >> ((((pattern >> 4) & 0x02) + ((pattern >> 1) & 0x01)) << 1)) & 0x03
+                color = (self.objectPalette0 >> ((((pattern >> 4) & 0x02) + \
+                        ((pattern >> 1) & 0x01)) << 1)) & 0x03
             else:
-                color = (self.objectPalette1 >> ((((pattern >> 4) & 0x02) + ((pattern >> 1) & 0x01)) << 1)) & 0x03
-            self.palette[((pattern & 0x30) << 4) + (pattern & 0x0F)] = constants.COLOR_MAP[color]
+                color = (self.objectPalette1 >> ((((pattern >> 4) & 0x02) +\
+                        ((pattern >> 1) & 0x01)) << 1)) & 0x03
+            index= ((pattern & 0x30) << 4) + (pattern & 0x0F)
+            self.palette[index] = constants.COLOR_MAP[color]
         self.dirty = False
 
-
 # ------------------------------------------------------------------------------
 
 class VideoDriver(object):
@@ -577,20 +587,20 @@
     def __init__(self):
         self.width = constants.GAMEBOY_SCREEN_WIDTH
         self.height = constants.GAMEBOY_SCREEN_HEIGHT
-        self.clearPixels()
+        self.clear_pixels()
         
-    def clearPixels(self):
+    def clear_pixels(self):
         self.pixels = [0] * self.width * self.height
             
-    def getWidth(self):
+    def get_width(self):
         return self.width
     
-    def getHeight(self):
+    def get_height(self):
         return selg.height
     
-    def getPixels(self):
+    def get_pixels(self):
         return self.pixels
     
-    def updateDisplay(self):
-        self.clearPixels()
+    def update_display(self):
+        self.clear_pixels()
         
\ No newline at end of file



More information about the Pypy-commit mailing list