--- M6502/Screen.pm 2007/08/01 12:57:15 76 +++ M6502/Screen.pm 2007/08/02 13:58:26 96 @@ -235,6 +235,34 @@ $app->sync; } +=head2 loop + +Implement SDL event loop + +=cut + +sub loop { + my $self = shift; + my $event = SDL::Event->new(); + + my $run_for = 2000; + + MAIN_LOOP: + while ( 1 ) { + while ($event->poll) { + my $type = $event->type(); + + last MAIN_LOOP if ($type == SDL_QUIT); + last MAIN_LOOP if ($type == SDL_KEYDOWN && $event->key_name() eq 'escape'); + + if ($type == SDL_KEYDOWN) { + $run_for = $self->cli; + } + } + M6502::exec($run_for); + } +} + =head1 SEE ALSO L is sample implementation using this module