[pypy-svn] r58746 - pypy/dist/pypy/lang/gameboy
cami at codespeak.net
cami at codespeak.net
Tue Oct 7 15:19:44 CEST 2008
Author: cami
Date: Tue Oct 7 15:19:44 2008
New Revision: 58746
Modified:
pypy/dist/pypy/lang/gameboy/gameboy.py
pypy/dist/pypy/lang/gameboy/gameboy_implementation.py
pypy/dist/pypy/lang/gameboy/timer.py
pypy/dist/pypy/lang/gameboy/video_mode.py
Log:
separated libsdl specific stuff in seprated methods
Modified: pypy/dist/pypy/lang/gameboy/gameboy.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/gameboy.py (original)
+++ pypy/dist/pypy/lang/gameboy/gameboy.py Tue Oct 7 15:19:44 2008
@@ -125,8 +125,8 @@
def write(self, address, data):
receiver = self.get_receiver(address)
if receiver is None:
- return
- #raise Exception("invalid read address given")
+ raise Exception("invalid read address given")
+ #return
receiver.write(address, data)
if address == constants.STAT or address == 0xFFFF:
self.cpu.handle_pending_interrupts()
@@ -134,8 +134,8 @@
def read(self, address):
receiver = self.get_receiver(address)
if receiver is None:
- return 0xFF
- #raise Exception("invalid read address given")
+ # raise Exception("invalid read address given")
+ return 0xFF
return receiver.read(address)
def print_receiver_msg(self, address, name):
Modified: pypy/dist/pypy/lang/gameboy/gameboy_implementation.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/gameboy_implementation.py (original)
+++ pypy/dist/pypy/lang/gameboy/gameboy_implementation.py Tue Oct 7 15:19:44 2008
@@ -30,25 +30,26 @@
self.joypad_driver = JoypadDriverImplementation()
self.video_driver = VideoDriverImplementation()
self.sound_driver = SoundDriverImplementation()
-
def mainLoop(self):
self.reset()
self.is_running = True
try:
while self.is_running:
- self.handle_events()
- self.emulate(constants.GAMEBOY_CLOCK >> 2)
- RSDL.Delay(1)
- except :
- self.is_running = False
- lltype.free(self.event, flavor='raw')
- RSDL.Quit()
- self.handle_execution_error()
+ self.emulate_cycle()
+ except Exception, error:
+ self.is_running = False
+ self.handle_execution_error(error)
return 0
- def handle_execution_error(self):
- pass
+ def emulate_cycle(self):
+ self.handle_events()
+ self.emulate(constants.GAMEBOY_CLOCK >> 2)
+ RSDL.Delay(1)
+
+ def handle_execution_error(self, error):
+ lltype.free(self.event, flavor='raw')
+ RSDL.Quit()
def handle_events(self):
self.poll_event()
Modified: pypy/dist/pypy/lang/gameboy/timer.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/timer.py (original)
+++ pypy/dist/pypy/lang/gameboy/timer.py Tue Oct 7 15:19:44 2008
@@ -146,21 +146,8 @@
if self.timer_counter == 0x00:
self.timer_counter = self.timer_modulo
self.timer_interrupt_flag.set_pending()
-
- #def emulate_timer(self, ticks):
- # if (self.timer_control & 0x04) == 0:
- # return
- # self.timer_cycles -= ticks
- # if self.timer_cycles > 0: return
- # count = int(math.ceil(-self.timer_cycles / self.timer_clock)) + 1
- # self.timer_cycles += self.timer_clock*count
- # # check for zero pass
- # if (self.timer_counter + count) > 0xFF:
- # self.interrupt.raise_interrupt(constants.TIMER)
- # zero_passes = math.ceil(self.timer_counter / count)
- # self.timer_counter = (self.timer_modulo + count - zero_passes ) % (0xFF +1)
- # else:
- # self.timer_counter = (self.timer_counter + count) % (0xFF +1)
+
+
# CLOCK DRIVER -----------------------------------------------------------------
class Clock(object):
Modified: pypy/dist/pypy/lang/gameboy/video_mode.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/video_mode.py (original)
+++ pypy/dist/pypy/lang/gameboy/video_mode.py Tue Oct 7 15:19:44 2008
@@ -15,11 +15,9 @@
Exception.__init__(self, "")
class Mode(object):
-
"""
The two lower STAT bits show the current status of the LCD controller.
"""
-
def __init__(self, video):
self.video = video
self.reset()
@@ -56,7 +54,6 @@
the CPU can access both the display RAM (8000h-9FFFh)
and OAM (FE00h-FE9Fh)
"""
-
def reset(self):
self.h_blank_interrupt = False
@@ -104,7 +101,6 @@
display is disabled) and the CPU can access both the
display RAM (8000h-9FFFh) and OAM (FE00h-FE9Fh)
"""
-
def reset(self):
self.v_blank_interrupt = False
@@ -168,7 +164,6 @@
The CPU <cannot> access OAM memory (FE00h-FE9Fh)
during this period.
"""
-
def reset(self):
self.oam_interrupt = False
@@ -198,7 +193,6 @@
The CPU <cannot> access OAM and VRAM during this period.
CGB Mode: Cannot access Palette Data (FF69,FF6B) either.
"""
-
def reset(self):
pass
More information about the Pypy-commit
mailing list