forked from len0rd/rockbox
Rockboy - gameboy emulation for rockbox, based on gnuboy. Still a bit early, but already playable on iRiver H1xx and the simulators. The archos recorder version is currently rather slow...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6104 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
48dad47df9
commit
384de10246
56 changed files with 9225 additions and 1 deletions
117
apps/plugins/rockboy/emu.c
Normal file
117
apps/plugins/rockboy/emu.c
Normal file
|
@ -0,0 +1,117 @@
|
|||
|
||||
|
||||
|
||||
#include "rockmacros.h"
|
||||
#include "defs.h"
|
||||
#include "regs.h"
|
||||
#include "hw.h"
|
||||
#include "cpu.h"
|
||||
#include "mem.h"
|
||||
#include "lcd.h"
|
||||
#include "rc.h"
|
||||
#include "sound.h"
|
||||
#include "rtc.h"
|
||||
|
||||
static int framelen = 16743;
|
||||
static int framecount;
|
||||
|
||||
rcvar_t emu_exports[] =
|
||||
{
|
||||
RCV_INT("framelen", &framelen),
|
||||
RCV_INT("framecount", &framecount),
|
||||
RCV_END
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* emu_reset is called to initialize the state of the emulated
|
||||
* system. It should set cpu registers, hardware registers, etc. to
|
||||
* their appropriate values at powerup time.
|
||||
*/
|
||||
|
||||
void emu_reset(void)
|
||||
{
|
||||
hw_reset();
|
||||
lcd_reset();
|
||||
cpu_reset();
|
||||
mbc_reset();
|
||||
sound_reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void emu_step(void)
|
||||
{
|
||||
cpu_emulate(cpu.lcdc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This mess needs to be moved to another module; it's just here to
|
||||
* make things work in the mean time. */
|
||||
|
||||
void emu_run(void)
|
||||
{
|
||||
void *timer = sys_timer();
|
||||
char meow[500];
|
||||
int delay;
|
||||
int framecount=0;
|
||||
|
||||
vid_begin();
|
||||
lcd_begin();
|
||||
while(shut==0)
|
||||
{
|
||||
cpu_emulate(2280);
|
||||
while (R_LY > 0 && R_LY < 144)
|
||||
emu_step();
|
||||
|
||||
vid_end();
|
||||
rtc_tick();
|
||||
sound_mix();
|
||||
if (!pcm_submit())
|
||||
{
|
||||
delay = framelen - sys_elapsed(timer);
|
||||
sys_sleep(delay);
|
||||
sys_elapsed(timer);
|
||||
}
|
||||
doevents();
|
||||
vid_begin();
|
||||
// if (framecount) { if (!--framecount) die("finished\n"); }
|
||||
|
||||
if (!(R_LCDC & 0x80))
|
||||
cpu_emulate(32832);
|
||||
|
||||
while (R_LY > 0) /* wait for next frame */
|
||||
emu_step();
|
||||
framecount++;
|
||||
snprintf(meow,499,"%d",framecount);
|
||||
rb->lcd_putsxy(0,0,meow);
|
||||
rb->lcd_update_rect(0,0,LCD_WIDTH,8);
|
||||
rb->yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue