forked from len0rd/rockbox
Code police and clean up for rockboy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15144 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0b911fefea
commit
437c3e40ca
26 changed files with 167 additions and 309 deletions
|
@ -18,7 +18,7 @@ endif
|
|||
|
||||
LINKFILE := $(OBJDIR)/link.lds
|
||||
DEPFILE = $(OBJDIR)/dep-rockboy
|
||||
SRC = cpu.c emu.c events.c fastmem.c hw.c lcd.c lcdc.c loader.c main.c \
|
||||
SRC = cpu.c emu.c events.c fastmem.c hw.c lcd.c lcdc.c loader.c \
|
||||
mem.c menu.c rbsound.c rockboy.c rtc.c save.c sound.c sys_rockbox.c \
|
||||
../../../firmware/common/sscanf.c
|
||||
|
||||
|
|
|
@ -23,9 +23,10 @@ struct cpu
|
|||
union reg pc, sp, bc, de, hl, af;
|
||||
#endif
|
||||
int ime, ima;
|
||||
int speed;
|
||||
int halt;
|
||||
int div, tim;
|
||||
unsigned int speed;
|
||||
unsigned int halt;
|
||||
unsigned int div;
|
||||
int tim;
|
||||
int lcdc;
|
||||
int snd;
|
||||
};
|
||||
|
@ -48,12 +49,7 @@ extern int blockclen;
|
|||
#endif
|
||||
|
||||
void cpu_reset(void);
|
||||
void div_advance(int cnt) ICODE_ATTR;
|
||||
void timer_advance(int cnt) ICODE_ATTR;
|
||||
void lcdc_advance(int cnt) ICODE_ATTR;
|
||||
void sound_advance(int cnt) ICODE_ATTR;
|
||||
void cpu_timers(int cnt) ICODE_ATTR;
|
||||
int cpu_emulate(int cycles) ICODE_ATTR;
|
||||
inline int cpu_step(int max) ICODE_ATTR;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,14 +37,14 @@ F = (F & (FL|FC)) | decflag_table[(r)]; }
|
|||
#define DECW(r) ( (r)-- )
|
||||
|
||||
#define ADD(n) { \
|
||||
W(acc) = (un16)A + (un16)(n); \
|
||||
W(acc) = (un32)A + (un32)(n); \
|
||||
F = (ZFLAG(LB(acc))) \
|
||||
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
|
||||
| (HB(acc) << 4); \
|
||||
A = LB(acc); }
|
||||
|
||||
#define ADC(n) { \
|
||||
W(acc) = (un16)A + (un16)(n) + (un16)((F&FC)>>4); \
|
||||
W(acc) = (un32)A + (un32)(n) + (un32)((F&FC)>>4); \
|
||||
F = (ZFLAG(LB(acc))) \
|
||||
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
|
||||
| (HB(acc) << 4); \
|
||||
|
@ -70,7 +70,7 @@ F = (FH & (((SP>>8) ^ ((n)>>8) ^ HB(acc)) << 1)) \
|
|||
HL = W(acc); }
|
||||
|
||||
#define CP(n) { \
|
||||
W(acc) = (un16)A - (un16)(n); \
|
||||
W(acc) = (un32)A - (un32)(n); \
|
||||
F = FN \
|
||||
| (ZFLAG(LB(acc))) \
|
||||
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
|
||||
|
@ -79,7 +79,7 @@ F = FN \
|
|||
#define SUB(n) { CP((n)); A = LB(acc); }
|
||||
|
||||
#define SBC(n) { \
|
||||
W(acc) = (un16)A - (un16)(n) - (un16)((F&FC)>>4); \
|
||||
W(acc) = (un32)A - (un32)(n) - (un32)((F&FC)>>4); \
|
||||
F = FN \
|
||||
| (ZFLAG((n8)LB(acc))) \
|
||||
| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
|
||||
|
@ -273,18 +273,19 @@ void cpu_reset(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
void div_advance(int cnt)
|
||||
static void div_advance(int cnt) ICODE_ATTR;
|
||||
static void div_advance(int cnt)
|
||||
{
|
||||
cpu.div += (cnt<<1);
|
||||
if (cpu.div >= 256)
|
||||
if (cpu.div >> 8)
|
||||
{
|
||||
R_DIV += (cpu.div >> 8);
|
||||
cpu.div &= 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
void timer_advance(int cnt)
|
||||
static void timer_advance(int cnt) ICODE_ATTR;
|
||||
static void timer_advance(int cnt)
|
||||
{
|
||||
int unit, tima;
|
||||
|
||||
|
@ -293,28 +294,30 @@ void timer_advance(int cnt)
|
|||
unit = ((-R_TAC) & 3) << 1;
|
||||
cpu.tim += (cnt<<unit);
|
||||
|
||||
if (cpu.tim >= 512)
|
||||
if (cpu.tim >> 9)
|
||||
{
|
||||
tima = R_TIMA + (cpu.tim >> 9);
|
||||
cpu.tim &= 0x1ff;
|
||||
if (tima >= 256)
|
||||
if (tima >> 8)
|
||||
{
|
||||
hw_interrupt(IF_TIMER, IF_TIMER);
|
||||
hw_interrupt(0, IF_TIMER);
|
||||
}
|
||||
while (tima >= 256)
|
||||
while (tima >> 8)
|
||||
tima = tima - 256 + R_TMA;
|
||||
R_TIMA = tima;
|
||||
}
|
||||
}
|
||||
|
||||
void lcdc_advance(int cnt)
|
||||
static void lcdc_advance(int cnt) ICODE_ATTR;
|
||||
static void lcdc_advance(int cnt)
|
||||
{
|
||||
cpu.lcdc -= cnt;
|
||||
if (cpu.lcdc <= 0) lcdc_trans();
|
||||
}
|
||||
|
||||
void sound_advance(int cnt)
|
||||
static void sound_advance(int cnt) ICODE_ATTR;
|
||||
static void sound_advance(int cnt)
|
||||
{
|
||||
cpu.snd += cnt;
|
||||
}
|
||||
|
@ -328,11 +331,16 @@ void cpu_timers(int cnt)
|
|||
sound_advance(cnt);
|
||||
}
|
||||
|
||||
int cpu_idle(int max)
|
||||
static int cpu_idle(int max)
|
||||
{
|
||||
int cnt, unit;
|
||||
|
||||
if (!(cpu.halt && IME)) return 0;
|
||||
if (R_IF & R_IE)
|
||||
{
|
||||
cpu.halt = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Make sure we don't miss lcdc status events! */
|
||||
if ((R_IE & (IF_VBLANK | IF_STAT)) && (max > cpu.lcdc))
|
||||
|
@ -878,7 +886,7 @@ next:
|
|||
PC++;
|
||||
if (R_KEY1 & 1)
|
||||
{
|
||||
cpu.speed = cpu.speed ^ 1;
|
||||
cpu.speed ^= 1;
|
||||
R_KEY1 = (R_KEY1 & 0x7E) | (cpu.speed << 7);
|
||||
break;
|
||||
}
|
||||
|
@ -996,27 +1004,3 @@ next:
|
|||
}
|
||||
|
||||
#endif /* ASM_CPU_EMULATE */
|
||||
|
||||
|
||||
#ifndef ASM_CPU_STEP
|
||||
|
||||
inline int cpu_step(int max)
|
||||
{
|
||||
register int cnt;
|
||||
if ((cnt = cpu_idle(max))) return cnt;
|
||||
return cpu_emulate(1);
|
||||
}
|
||||
|
||||
#endif /* ASM_CPU_STEP */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "lcd-gb.h"
|
||||
#include "sound.h"
|
||||
#include "rtc-gb.h"
|
||||
#include "pcm.h"
|
||||
|
||||
/*
|
||||
* emu_reset is called to initialize the state of the emulated
|
||||
|
@ -23,7 +24,7 @@ void emu_reset(void)
|
|||
sound_reset();
|
||||
}
|
||||
|
||||
void emu_step(void)
|
||||
static void emu_step(void)
|
||||
{
|
||||
cpu_emulate(cpu.lcdc);
|
||||
}
|
||||
|
|
|
@ -10,15 +10,15 @@
|
|||
|
||||
struct fb
|
||||
{
|
||||
fb_data *ptr;
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
struct
|
||||
{
|
||||
int l, r;
|
||||
} cc[3];
|
||||
int enabled;
|
||||
#if !defined(HAVE_LCD_COLOR)
|
||||
#else
|
||||
int mode;
|
||||
#endif
|
||||
int enabled;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -63,8 +63,7 @@ void hw_hdma(void)
|
|||
|
||||
sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0);
|
||||
da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0);
|
||||
cnt = 16;
|
||||
while (cnt--)
|
||||
for (cnt=16; cnt>0; cnt--)
|
||||
writeb(da++, readb(sa++));
|
||||
cpu_timers(16);
|
||||
R_HDMA1 = sa >> 8;
|
||||
|
@ -93,12 +92,11 @@ void hw_hdma_cmd(byte c)
|
|||
/* Perform GDMA */
|
||||
sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0);
|
||||
da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0);
|
||||
cnt = ((int)c)+1;
|
||||
cnt = (((int)c)+1) << 4;
|
||||
/* FIXME - this should use cpu time! */
|
||||
/*cpu_timers(102 * cnt);*/
|
||||
cpu_timers((460>>cpu.speed)+cnt*16); /*dalias*/
|
||||
cpu_timers((460>>cpu.speed)+cnt); /*dalias*/
|
||||
/*cpu_timers(228 + (16*cnt));*/ /* this should be right according to no$ */
|
||||
cnt <<= 4;
|
||||
while (cnt--)
|
||||
writeb(da++, readb(sa++));
|
||||
R_HDMA1 = sa >> 8;
|
||||
|
@ -115,7 +113,7 @@ void hw_hdma_cmd(byte c)
|
|||
* interrupt line) if a transition has been made.
|
||||
*/
|
||||
|
||||
void pad_refresh()
|
||||
void pad_refresh(void)
|
||||
{
|
||||
byte oldp1;
|
||||
oldp1 = R_P1;
|
||||
|
@ -139,7 +137,8 @@ void pad_refresh()
|
|||
* pad.
|
||||
*/
|
||||
|
||||
void pad_press(byte k)
|
||||
static void pad_press(byte k) ICODE_ATTR;
|
||||
static void pad_press(byte k)
|
||||
{
|
||||
if (hw.pad & k)
|
||||
return;
|
||||
|
@ -147,7 +146,8 @@ void pad_press(byte k)
|
|||
pad_refresh();
|
||||
}
|
||||
|
||||
void pad_release(byte k)
|
||||
static void pad_release(byte k) ICODE_ATTR;
|
||||
static void pad_release(byte k)
|
||||
{
|
||||
if (!(hw.pad & k))
|
||||
return;
|
||||
|
@ -160,7 +160,7 @@ void pad_set(byte k, int st)
|
|||
st ? pad_press(k) : pad_release(k);
|
||||
}
|
||||
|
||||
void hw_reset()
|
||||
void hw_reset(void)
|
||||
{
|
||||
hw.ilines = hw.pad = 0;
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ void hw_dma(byte b) ICODE_ATTR;
|
|||
void hw_hdma_cmd(byte c) ICODE_ATTR;
|
||||
void hw_hdma(void) ICODE_ATTR;
|
||||
void pad_refresh(void) ICODE_ATTR;
|
||||
void pad_press(byte k) ICODE_ATTR;
|
||||
void pad_release(byte k) ICODE_ATTR;
|
||||
void pad_set(byte k, int st) ICODE_ATTR;
|
||||
void hw_reset(void);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ struct vissprite
|
|||
{
|
||||
byte *buf;
|
||||
int x;
|
||||
byte pal, pri, pad[6];
|
||||
byte pal, pri;
|
||||
};
|
||||
|
||||
struct scan
|
||||
|
@ -51,15 +51,6 @@ struct lcd
|
|||
extern struct lcd lcd;
|
||||
extern struct scan scan;
|
||||
|
||||
|
||||
void updatepatpix(void) ICODE_ATTR;
|
||||
void tilebuf(void) ICODE_ATTR;
|
||||
void bg_scan(void) ICODE_ATTR;
|
||||
void wnd_scan(void) ICODE_ATTR;
|
||||
void bg_scan_pri(void) ICODE_ATTR;
|
||||
void wnd_scan_pri(void) ICODE_ATTR;
|
||||
void spr_enum(void) ICODE_ATTR;
|
||||
void spr_scan(void) ICODE_ATTR;
|
||||
void lcd_begin(void) ICODE_ATTR;
|
||||
void lcd_refreshline(void) ICODE_ATTR;
|
||||
void pal_write(int i, byte b) ICODE_ATTR;
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
#include "mem.h"
|
||||
#include "lcd-gb.h"
|
||||
#include "fb.h"
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
#include "palette-presets.h"
|
||||
#endif
|
||||
#ifdef USE_ASM
|
||||
#include "asm.h"
|
||||
#endif
|
||||
|
@ -59,7 +61,8 @@ static int dmg_pal[4][4];
|
|||
fb_data *vdest;
|
||||
|
||||
#ifndef ASM_UPDATEPATPIX
|
||||
void updatepatpix(void)
|
||||
static void updatepatpix(void) ICODE_ATTR;
|
||||
static void updatepatpix(void)
|
||||
{
|
||||
int i, j;
|
||||
#if ((CONFIG_CPU != SH7034) && !defined(CPU_COLDFIRE))
|
||||
|
@ -366,7 +369,8 @@ void updatepatpix(void)
|
|||
|
||||
|
||||
|
||||
void tilebuf(void)
|
||||
static void tilebuf(void) ICODE_ATTR;
|
||||
static void tilebuf(void)
|
||||
{
|
||||
int i, cnt;
|
||||
int base;
|
||||
|
@ -468,7 +472,8 @@ void tilebuf(void)
|
|||
* WX = WND start (if 0, no need to do anything) -> WY
|
||||
* U = start...something...thingy... 7 at most
|
||||
*/
|
||||
void bg_scan(void)
|
||||
static void bg_scan(void) ICODE_ATTR;
|
||||
static void bg_scan(void)
|
||||
{
|
||||
int cnt;
|
||||
byte *src, *dest;
|
||||
|
@ -508,7 +513,8 @@ void bg_scan(void)
|
|||
*(dest++) = *(src++);
|
||||
}
|
||||
|
||||
void wnd_scan(void)
|
||||
static void wnd_scan(void) ICODE_ATTR;
|
||||
static void wnd_scan(void)
|
||||
{
|
||||
int cnt;
|
||||
byte *src, *dest;
|
||||
|
@ -554,7 +560,8 @@ static int priused(void *attr)
|
|||
return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080);
|
||||
}
|
||||
|
||||
void bg_scan_pri(void)
|
||||
static void bg_scan_pri(void) ICODE_ATTR;
|
||||
static void bg_scan_pri(void)
|
||||
{
|
||||
int cnt, i;
|
||||
byte *src, *dest;
|
||||
|
@ -584,7 +591,8 @@ void bg_scan_pri(void)
|
|||
memset(dest, src[i&31]&128, cnt);
|
||||
}
|
||||
|
||||
void wnd_scan_pri(void)
|
||||
static void wnd_scan_pri(void) ICODE_ATTR;
|
||||
static void wnd_scan_pri(void)
|
||||
{
|
||||
int cnt, i;
|
||||
byte *src, *dest;
|
||||
|
@ -610,7 +618,7 @@ void wnd_scan_pri(void)
|
|||
memset(dest, src[i]&128, cnt);
|
||||
}
|
||||
|
||||
void bg_scan_color(void)
|
||||
static void bg_scan_color(void)
|
||||
{
|
||||
int cnt;
|
||||
byte *src, *dest;
|
||||
|
@ -684,7 +692,7 @@ void bg_scan_color(void)
|
|||
blendcpy(dest, src, *(tile++), cnt);
|
||||
}
|
||||
|
||||
void wnd_scan_color(void)
|
||||
static void wnd_scan_color(void)
|
||||
{
|
||||
int cnt;
|
||||
byte *src, *dest;
|
||||
|
@ -706,12 +714,8 @@ void wnd_scan_color(void)
|
|||
blendcpy(dest, src, *(tile++), cnt);
|
||||
}
|
||||
|
||||
static void recolor(byte *buf, byte fill, int cnt)
|
||||
{
|
||||
while (cnt--) *(buf++) |= fill;
|
||||
}
|
||||
|
||||
void spr_enum(void)
|
||||
static void spr_enum(void) ICODE_ATTR;
|
||||
static void spr_enum(void)
|
||||
{
|
||||
int i, j;
|
||||
struct obj *o;
|
||||
|
@ -771,7 +775,8 @@ void spr_enum(void)
|
|||
}
|
||||
}
|
||||
|
||||
void spr_scan(void)
|
||||
static void spr_scan(void) ICODE_ATTR;
|
||||
static void spr_scan(void)
|
||||
{
|
||||
int i, x;
|
||||
byte pal, b, ns = NS;
|
||||
|
@ -874,26 +879,27 @@ void lcd_begin(void)
|
|||
#define S3R ((LCD_HEIGHT-((160*DXR)>>16))/2)*LCD_WIDTH+LCD_WIDTH-1
|
||||
#endif
|
||||
|
||||
vdest=rb->lcd_framebuffer;
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
set_pal();
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
if(options.rotate)
|
||||
{
|
||||
if(options.fullscreen == 0)
|
||||
vdest=fb.ptr+S2R;
|
||||
else if (options.fullscreen == 1)
|
||||
vdest=fb.ptr+S3R;
|
||||
if(options.scaling == 0)
|
||||
vdest+=+S2R;
|
||||
else if (options.scaling == 1)
|
||||
vdest+=S3R;
|
||||
else
|
||||
vdest=fb.ptr+S1R;
|
||||
vdest+=S1R;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(options.fullscreen == 0)
|
||||
vdest=fb.ptr+S2;
|
||||
else if (options.fullscreen == 1)
|
||||
vdest=fb.ptr+S3;
|
||||
if(options.scaling == 0)
|
||||
vdest+=S2;
|
||||
else if (options.scaling == 1)
|
||||
vdest+=S3;
|
||||
else
|
||||
vdest=fb.ptr+S1;
|
||||
vdest+=S1;
|
||||
}
|
||||
#endif
|
||||
WY = R_WY;
|
||||
|
@ -911,7 +917,7 @@ int sremain IDATA_ATTR=LCD_WIDTH-160;
|
|||
void setvidmode(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
switch(options.fullscreen)
|
||||
switch(options.scaling)
|
||||
{
|
||||
case 0:
|
||||
if(options.rotate)
|
||||
|
@ -1036,7 +1042,6 @@ void lcd_refreshline(void)
|
|||
|
||||
bg_scan();
|
||||
wnd_scan();
|
||||
recolor(BUF+WX, 0x04, 160-WX);
|
||||
}
|
||||
spr_scan();
|
||||
|
||||
|
@ -1097,13 +1102,13 @@ void lcd_refreshline(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
void set_pal(void)
|
||||
{
|
||||
memcpy(dmg_pal,palettes[options.pal], sizeof dmg_pal);
|
||||
memcpy(dmg_pal,palettes[options.pal], sizeof(dmg_pal));
|
||||
pal_dirty();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
static void updatepalette(int i)
|
||||
{
|
||||
int c, r, g, b;
|
||||
|
@ -1127,13 +1132,13 @@ static void updatepalette(int i)
|
|||
#endif
|
||||
PAL[i] = c;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
|
||||
void pal_write(int i, byte b)
|
||||
{
|
||||
if (lcd.pal[i] == b) return;
|
||||
lcd.pal[i] = b;
|
||||
#if LCD_DEPTH ==16
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
updatepalette(i>>1);
|
||||
#endif
|
||||
}
|
||||
|
@ -1175,7 +1180,7 @@ void vram_dirty(void)
|
|||
|
||||
void pal_dirty(void)
|
||||
{
|
||||
#if LCD_DEPTH ==16
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
int i;
|
||||
#endif
|
||||
if (!hw.cgb)
|
||||
|
@ -1186,7 +1191,7 @@ void pal_dirty(void)
|
|||
pal_write_dmg(64, 2, R_OBP0);
|
||||
pal_write_dmg(72, 3, R_OBP1);
|
||||
}
|
||||
#if LCD_DEPTH ==16
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
for (i = 0; i < 64; i++)
|
||||
updatepalette(i);
|
||||
#endif
|
||||
|
@ -1198,19 +1203,3 @@ void lcd_reset(void)
|
|||
lcd_begin();
|
||||
vram_dirty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,9 +47,8 @@ void stat_trigger(void)
|
|||
* update the STAT interrupt line.
|
||||
*/
|
||||
|
||||
static void stat_change(int stat)
|
||||
static void stat_change(unsigned int stat)
|
||||
{
|
||||
stat &= 3;
|
||||
R_STAT = (R_STAT & 0x7C) | stat;
|
||||
|
||||
if (stat != 1) hw_interrupt(0, IF_VBLANK);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* 11 - ROM+MBC3
|
||||
*/
|
||||
|
||||
static int mbc_table[256] =
|
||||
static const int mbc_table[256] =
|
||||
{
|
||||
MBC_NONE,
|
||||
MBC_MBC1,
|
||||
|
@ -81,7 +81,7 @@ static int mbc_table[256] =
|
|||
MBC_HUC1
|
||||
};
|
||||
|
||||
static unsigned short romsize_table[56] =
|
||||
static const unsigned short romsize_table[56] =
|
||||
{
|
||||
2, 4, 8, 16, 32, 64, 128, 256,
|
||||
512, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
@ -94,7 +94,7 @@ static unsigned short romsize_table[56] =
|
|||
};
|
||||
|
||||
/* Ram size should be no larger then 16 banks 1Mbit */
|
||||
static unsigned char ramsize_table[5] =
|
||||
static const unsigned char ramsize_table[5] =
|
||||
{
|
||||
0, 1, 1, 4, 16
|
||||
};
|
||||
|
@ -104,8 +104,6 @@ static char sramfile[500];
|
|||
static char rtcfile[500];
|
||||
static char saveprefix[500];
|
||||
|
||||
static int saveslot;
|
||||
|
||||
static int forcebatt, nobatt;
|
||||
static int forcedmg;
|
||||
|
||||
|
@ -142,7 +140,7 @@ static byte *loadfile(int fd, int *len)
|
|||
return d;
|
||||
}
|
||||
|
||||
int rom_load(void)
|
||||
static int rom_load(void)
|
||||
{
|
||||
int fd;
|
||||
byte c, *data, *header;
|
||||
|
@ -220,7 +218,7 @@ int rom_load(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sram_load(void)
|
||||
static int sram_load(void)
|
||||
{
|
||||
int fd;
|
||||
char meow[500];
|
||||
|
@ -243,7 +241,7 @@ int sram_load(void)
|
|||
}
|
||||
|
||||
|
||||
int sram_save(void)
|
||||
static int sram_save(void)
|
||||
{
|
||||
int fd;
|
||||
char meow[500];
|
||||
|
@ -261,45 +259,7 @@ int sram_save(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void state_save(int n)
|
||||
{
|
||||
int fd;
|
||||
char name[500];
|
||||
|
||||
if (n < 0) n = saveslot;
|
||||
if (n < 0) n = 0;
|
||||
snprintf(name, 499,"%s.%03d", saveprefix, n);
|
||||
|
||||
if ((fd = open(name, O_WRONLY|O_CREAT|O_TRUNC)>=0))
|
||||
{
|
||||
savestate(fd);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void state_load(int n)
|
||||
{
|
||||
int fd;
|
||||
char name[500];
|
||||
|
||||
if (n < 0) n = saveslot;
|
||||
if (n < 0) n = 0;
|
||||
snprintf(name, 499, "%s.%03d", saveprefix, n);
|
||||
|
||||
if ((fd = open(name, O_RDONLY)>=0))
|
||||
{
|
||||
loadstate(fd);
|
||||
close(fd);
|
||||
vram_dirty();
|
||||
pal_dirty();
|
||||
sound_dirty();
|
||||
mem_updatemap();
|
||||
}
|
||||
}
|
||||
|
||||
void rtc_save(void)
|
||||
static void rtc_save(void)
|
||||
{
|
||||
int fd;
|
||||
if (!rtc.batt) return;
|
||||
|
@ -308,7 +268,7 @@ void rtc_save(void)
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void rtc_load(void)
|
||||
static void rtc_load(void)
|
||||
{
|
||||
int fd;
|
||||
if (!rtc.batt) return;
|
||||
|
@ -317,21 +277,6 @@ void rtc_load(void)
|
|||
close(fd);
|
||||
}
|
||||
|
||||
|
||||
void loader_unload(void)
|
||||
{
|
||||
sram_save();
|
||||
/* if (romfile) free(romfile);
|
||||
if (sramfile) free(sramfile);
|
||||
if (saveprefix) free(saveprefix);
|
||||
if (rom.bank) free(rom.bank);
|
||||
if (ram.sbank) free(ram.sbank); */
|
||||
romfile = 0;
|
||||
rom.bank = 0;
|
||||
ram.sbank = 0;
|
||||
mbc.type = mbc.romsize = mbc.ramsize = mbc.batt = 0;
|
||||
}
|
||||
|
||||
void cleanup(void)
|
||||
{
|
||||
sram_save();
|
||||
|
|
|
@ -3,23 +3,6 @@
|
|||
#ifndef __LOADER_H__
|
||||
#define __LOADER_H__
|
||||
|
||||
|
||||
typedef struct loader_s
|
||||
{
|
||||
char *rom;
|
||||
char *base;
|
||||
char *sram;
|
||||
char *state;
|
||||
int ramloaded;
|
||||
} loader_t;
|
||||
|
||||
|
||||
extern loader_t loader;
|
||||
|
||||
|
||||
int rom_load(void);
|
||||
int sram_load(void);
|
||||
int sram_save(void);
|
||||
void loader_init(char *s);
|
||||
void cleanup(void);
|
||||
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#include "rockmacros.h"
|
||||
#include "input.h"
|
||||
#include "emu.h"
|
||||
#include "loader.h"
|
||||
#include "hw.h"
|
||||
|
||||
void doevents()
|
||||
{
|
||||
event_t ev;
|
||||
int st;
|
||||
|
||||
ev_poll();
|
||||
while (ev_getevent(&ev))
|
||||
{
|
||||
if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
|
||||
continue;
|
||||
st = (ev.type != EV_RELEASE);
|
||||
pad_set(ev.code, st);
|
||||
}
|
||||
}
|
||||
|
||||
int gnuboy_main(char *rom)
|
||||
{
|
||||
rb->lcd_puts(0,0,"Init video");
|
||||
vid_init();
|
||||
rb->lcd_puts(0,1,"Init sound");
|
||||
pcm_init();
|
||||
rb->lcd_puts(0,2,"Loading rom");
|
||||
loader_init(rom);
|
||||
if(shut)
|
||||
return PLUGIN_ERROR;
|
||||
rb->lcd_puts(0,3,"Emu reset");
|
||||
emu_reset();
|
||||
rb->lcd_puts(0,4,"Emu run");
|
||||
rb->lcd_clear_display();
|
||||
rb->lcd_update();
|
||||
emu_run();
|
||||
|
||||
/* never reached */
|
||||
return PLUGIN_OK;
|
||||
}
|
|
@ -28,7 +28,7 @@ struct ram ram;
|
|||
* make the old maps potentially invalid.
|
||||
*/
|
||||
|
||||
void mem_updatemap()
|
||||
void mem_updatemap(void)
|
||||
{
|
||||
int n;
|
||||
static byte **map;
|
||||
|
@ -93,7 +93,8 @@ void mem_updatemap()
|
|||
* byte value to be written.
|
||||
*/
|
||||
|
||||
void ioreg_write(byte r, byte b)
|
||||
static void ioreg_write(byte r, byte b) ICODE_ATTR;
|
||||
static void ioreg_write(byte r, byte b)
|
||||
{
|
||||
if (!hw.cgb)
|
||||
{
|
||||
|
@ -225,7 +226,7 @@ void ioreg_write(byte r, byte b)
|
|||
}
|
||||
|
||||
|
||||
byte ioreg_read(byte r)
|
||||
static byte ioreg_read(byte r)
|
||||
{
|
||||
switch(r)
|
||||
{
|
||||
|
@ -282,7 +283,8 @@ byte ioreg_read(byte r)
|
|||
* and a byte value written to the address.
|
||||
*/
|
||||
|
||||
void mbc_write(int a, byte b)
|
||||
static void mbc_write(int a, byte b) ICODE_ATTR;
|
||||
static void mbc_write(int a, byte b)
|
||||
{
|
||||
byte ha = (a>>12);
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ extern struct rom rom;
|
|||
extern struct ram ram;
|
||||
|
||||
void mem_updatemap(void) ICODE_ATTR;
|
||||
void ioreg_write(byte r, byte b) ICODE_ATTR;
|
||||
void mbc_write(int a, byte b) ICODE_ATTR;
|
||||
void mem_write(int a, byte b) ICODE_ATTR;
|
||||
byte mem_read(int a) ICODE_ATTR;
|
||||
void mbc_reset(void);
|
||||
|
|
|
@ -7,16 +7,17 @@
|
|||
#include "button.h"
|
||||
#include "rockmacros.h"
|
||||
#include "mem.h"
|
||||
#include "save.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
#include "rtc-gb.h"
|
||||
|
||||
#if (CONFIG_KEYPAD == IPOD_4G_PAD)
|
||||
#if CONFIG_KEYPAD == IPOD_4G_PAD
|
||||
#define MENU_BUTTON_UP BUTTON_SCROLL_BACK
|
||||
#define MENU_BUTTON_DOWN BUTTON_SCROLL_FWD
|
||||
#define MENU_BUTTON_LEFT BUTTON_LEFT
|
||||
#define MENU_BUTTON_RIGHT BUTTON_RIGHT
|
||||
|
||||
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
||||
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
||||
#define MENU_BUTTON_UP BUTTON_SCROLL_UP
|
||||
#define MENU_BUTTON_DOWN BUTTON_SCROLL_DOWN
|
||||
#define MENU_BUTTON_LEFT BUTTON_LEFT
|
||||
|
@ -37,7 +38,7 @@ static void munge_name(char *buf, size_t bufsiz);
|
|||
/* directory ROM save slots belong in */
|
||||
#define STATE_DIR ROCKBOX_DIR "/rockboy"
|
||||
|
||||
int getbutton(char *text)
|
||||
static int getbutton(char *text)
|
||||
{
|
||||
int fw, fh;
|
||||
rb->lcd_clear_display();
|
||||
|
@ -59,7 +60,7 @@ int getbutton(char *text)
|
|||
}
|
||||
}
|
||||
|
||||
void setupkeys(void)
|
||||
static void setupkeys(void)
|
||||
{
|
||||
options.UP=getbutton ("Press Up");
|
||||
options.DOWN=getbutton ("Press Down");
|
||||
|
@ -348,7 +349,7 @@ static void do_opt_menu(void)
|
|||
};
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
static const struct opt_items fullscreen[]= {
|
||||
static const struct opt_items scaling[]= {
|
||||
{ "Scaled", -1 },
|
||||
{ "Scaled - Maintain Ratio", -1 },
|
||||
#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
|
||||
|
@ -417,8 +418,8 @@ static void do_opt_menu(void)
|
|||
break;
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
case 4: /* Screen Size */
|
||||
rb->set_option(items[4].desc, &options.fullscreen, INT, fullscreen,
|
||||
sizeof(fullscreen)/sizeof(*fullscreen), NULL );
|
||||
rb->set_option(items[4].desc, &options.scaling, INT, scaling,
|
||||
sizeof(scaling)/sizeof(*scaling), NULL );
|
||||
setvidmode();
|
||||
break;
|
||||
case 5: /* Screen rotate */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: palette-presets.h $
|
||||
* $Id$
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
|
|
|
@ -15,6 +15,9 @@ struct pcm
|
|||
|
||||
extern struct pcm pcm;
|
||||
|
||||
void pcm_init(void);
|
||||
int pcm_submit(void);
|
||||
void pcm_close(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ static unsigned short *buf=0, *hwbuf=0;
|
|||
|
||||
static bool newly_started;
|
||||
|
||||
void get_more(unsigned char** start, size_t* size)
|
||||
static void get_more(unsigned char** start, size_t* size)
|
||||
{
|
||||
memcpy(hwbuf, &buf[pcm.len*doneplay], BUF_SIZE*sizeof(short));
|
||||
*start = (unsigned char*)(hwbuf);
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
#include "plugin.h"
|
||||
#include "loader.h"
|
||||
#include "rockmacros.h"
|
||||
#include "input.h"
|
||||
#include "emu.h"
|
||||
#include "hw.h"
|
||||
#include "pcm.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
@ -29,8 +33,6 @@ PLUGIN_IRAM_DECLARE
|
|||
struct plugin_api* rb;
|
||||
int shut,cleanshut;
|
||||
char *errormsg;
|
||||
int gnuboy_main(char *rom);
|
||||
void pcm_close(void);
|
||||
|
||||
#define optionname "options"
|
||||
|
||||
|
@ -65,7 +67,7 @@ void* memcpy(void* dst, const void* src, size_t size)
|
|||
return rb->memcpy(dst, src, size);
|
||||
}
|
||||
|
||||
void setoptions (void)
|
||||
static void setoptions (void)
|
||||
{
|
||||
int fd;
|
||||
DIR* dir;
|
||||
|
@ -85,7 +87,7 @@ void setoptions (void)
|
|||
options.LEFT=BUTTON_LEFT;
|
||||
options.RIGHT=BUTTON_RIGHT;
|
||||
|
||||
#if (CONFIG_KEYPAD == IRIVER_H100_PAD)
|
||||
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
||||
options.UP=BUTTON_UP;
|
||||
options.DOWN=BUTTON_DOWN;
|
||||
|
||||
|
@ -95,7 +97,7 @@ void setoptions (void)
|
|||
options.SELECT=BUTTON_SELECT;
|
||||
options.MENU=BUTTON_MODE;
|
||||
|
||||
#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||
#elif CONFIG_KEYPAD == IRIVER_H300_PAD
|
||||
options.UP=BUTTON_UP;
|
||||
options.DOWN=BUTTON_DOWN;
|
||||
|
||||
|
@ -190,9 +192,9 @@ void setoptions (void)
|
|||
options.fps=0;
|
||||
options.showstats=0;
|
||||
#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
|
||||
options.fullscreen=0;
|
||||
options.scaling=0;
|
||||
#else
|
||||
options.fullscreen=1;
|
||||
options.scaling=1;
|
||||
#endif
|
||||
options.sound=1;
|
||||
options.pal=0;
|
||||
|
@ -203,7 +205,7 @@ void setoptions (void)
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void savesettings(void)
|
||||
static void savesettings(void)
|
||||
{
|
||||
int fd;
|
||||
char optionsave[sizeof(savedir)+sizeof(optionname)];
|
||||
|
@ -218,6 +220,42 @@ void savesettings(void)
|
|||
}
|
||||
}
|
||||
|
||||
void doevents(void)
|
||||
{
|
||||
event_t ev;
|
||||
int st;
|
||||
|
||||
ev_poll();
|
||||
while (ev_getevent(&ev))
|
||||
{
|
||||
if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
|
||||
continue;
|
||||
st = (ev.type != EV_RELEASE);
|
||||
pad_set(ev.code, st);
|
||||
}
|
||||
}
|
||||
|
||||
static int gnuboy_main(char *rom)
|
||||
{
|
||||
rb->lcd_puts(0,0,"Init video");
|
||||
vid_init();
|
||||
rb->lcd_puts(0,1,"Init sound");
|
||||
pcm_init();
|
||||
rb->lcd_puts(0,2,"Loading rom");
|
||||
loader_init(rom);
|
||||
if(shut)
|
||||
return PLUGIN_ERROR;
|
||||
rb->lcd_puts(0,3,"Emu reset");
|
||||
emu_reset();
|
||||
rb->lcd_puts(0,4,"Emu run");
|
||||
rb->lcd_clear_display();
|
||||
rb->lcd_update();
|
||||
emu_run();
|
||||
|
||||
/* never reached */
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||
{
|
||||
|
|
|
@ -31,18 +31,13 @@ extern int shut,cleanshut;
|
|||
void vid_init(void);
|
||||
inline void vid_begin(void);
|
||||
void die(char *message, ...);
|
||||
void *sys_timer(void);
|
||||
int sys_elapsed(long *oldtick);
|
||||
int pcm_submit(void);
|
||||
void pcm_init(void);
|
||||
void doevents(void) ICODE_ATTR;
|
||||
void ev_poll(void);
|
||||
int do_user_menu(void);
|
||||
void loadstate(int fd);
|
||||
void savestate(int fd);
|
||||
void setvidmode(void);
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
void set_pal(void);
|
||||
#if !defined(HAVE_LCD_COLOR)
|
||||
#else
|
||||
void vid_update(int scanline);
|
||||
#endif
|
||||
#ifdef DYNAREC
|
||||
|
@ -106,7 +101,7 @@ struct options {
|
|||
int A, B, START, SELECT, MENU;
|
||||
int UP, DOWN, LEFT, RIGHT;
|
||||
int frameskip, fps, maxskip;
|
||||
int sound, fullscreen, showstats;
|
||||
int sound, scaling, showstats;
|
||||
int rotate;
|
||||
int pal;
|
||||
int dirty;
|
||||
|
|
|
@ -58,7 +58,7 @@ void rtc_write(byte b)
|
|||
}
|
||||
}
|
||||
|
||||
void rtc_tick()
|
||||
void rtc_tick(void)
|
||||
{
|
||||
if (rtc.stop) return;
|
||||
if (++rtc.t == 60)
|
||||
|
|
|
@ -274,22 +274,3 @@ void savestate(int fd)
|
|||
lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
|
||||
write(fd,ram.sbank, 4096*srl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,2 @@
|
|||
void loadstate(int fd);
|
||||
void savestate(int fd);
|
||||
void state_save(int n);
|
||||
void state_load(int n);
|
||||
|
|
|
@ -302,7 +302,7 @@ static void gbSoundChannel3(int *r, int *l)
|
|||
}
|
||||
}
|
||||
|
||||
void gbSoundChannel4(int *r, int *l)
|
||||
static void gbSoundChannel4(int *r, int *l)
|
||||
{
|
||||
int vol = S4.envol;
|
||||
|
||||
|
@ -669,7 +669,7 @@ void sound_write(byte r, byte b)
|
|||
snd.gbDigitalSound = false;
|
||||
}
|
||||
|
||||
void sound_reset()
|
||||
void sound_reset(void)
|
||||
{
|
||||
snd.level1 = 7;
|
||||
snd.level2 = 7;
|
||||
|
@ -737,7 +737,7 @@ void sound_reset()
|
|||
else snd.rate = 0;
|
||||
}
|
||||
|
||||
void sound_dirty()
|
||||
void sound_dirty(void)
|
||||
{
|
||||
sound_write(RI_NR10, R_NR10);
|
||||
sound_write(RI_NR11, R_NR11);
|
||||
|
|
|
@ -24,12 +24,10 @@
|
|||
#include "hw.h"
|
||||
#include "config.h"
|
||||
|
||||
#if (CONFIG_KEYPAD == SANSA_E200_PAD)
|
||||
|
||||
#if CONFIG_KEYPAD == SANSA_E200_PAD
|
||||
#define ROCKBOY_SCROLLWHEEL
|
||||
#define ROCKBOY_SCROLLWHEEL_CC BUTTON_SCROLL_UP
|
||||
#define ROCKBOY_SCROLLWHEEL_CW BUTTON_SCROLL_DOWN
|
||||
|
||||
#endif
|
||||
|
||||
struct fb fb IBSS_ATTR;
|
||||
|
@ -210,7 +208,6 @@ inline void vid_begin(void)
|
|||
void vid_init(void)
|
||||
{
|
||||
fb.enabled=1;
|
||||
fb.ptr=rb->lcd_framebuffer;
|
||||
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue