\r
PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)\r
{\r
- if (((int)dest & (int)src & 3) == 0)\r
+ if ((((int)dest | (int)src) & 3) == 0)\r
{\r
if (count >= 32) {\r
memcpy32((int *)dest, (int *)src, count/2);\r
bne DoInterrupt_mode1\r
tst r1,#2\r
bne DoInterrupt_mode2\r
- b DoInterrupt_mode0\r
\r
DoInterrupt_mode0:\r
;@ get 3 byte vector\r
{\r
afterEI = 0;\r
Cz80_Check_Interrupt:\r
- CHECK_INT\r
+ if (CPU->IRQState != CLEAR_LINE)\r
+ {\r
+ CHECK_INT\r
+ }\r
goto Cz80_Exec;\r
}\r
}\r
#define POST_IO \\r
// CCnt = io_cycle_counter;\r
\r
-#ifndef FAME_BIG_ENDIAN\r
+#define READ_BYTE_F(A, D) \\r
+ D = m68kcontext.read_byte(A) & 0xFF;\r
+\r
+#define READ_WORD_F(A, D) \\r
+ D = m68kcontext.read_word(A) & 0xFFFF;\r
\r
- #define READ_BYTE_F(A, D) \\r
- D = m68kcontext.read_byte(A) & 0xFF;\r
+#define READ_LONG_F(A, D) \\r
+ D = m68kcontext.read_long(A);\r
\r
- #define READ_WORD_F(A, D) \\r
- D = m68kcontext.read_word(A) & 0xFFFF;\r
+#define READSX_LONG_F READ_LONG_F\r
\r
- #define READ_LONG_F(A, D) \\r
- D = m68kcontext.read_word((A)) << 16; \\r
- D |= m68kcontext.read_word((A) + 2) & 0xFFFF;\r
+#define WRITE_LONG_F(A, D) \\r
+ m68kcontext.write_long(A, D);\r
\r
- #define READSX_LONG_F(A, D) \\r
- D = m68kcontext.read_word((A)) << 16; \\r
- D |= m68kcontext.read_word((A) + 2) & 0xFFFF;\r
+#define WRITE_LONG_DEC_F(A, D) \\r
+ m68kcontext.write_word((A) + 2, (D) & 0xFFFF); \\r
+ m68kcontext.write_word((A), (D) >> 16);\r
\r
- #define WRITE_LONG_F(A, D) \\r
- m68kcontext.write_word((A), (D) >> 16); \\r
- m68kcontext.write_word((A) + 2, (D) & 0xFFFF);\r
+#define PUSH_32_F(D) \\r
+ AREG(7) -= 4; \\r
+ m68kcontext.write_long(AREG(7), D);\r
\r
- #define WRITE_LONG_DEC_F(A, D) \\r
- m68kcontext.write_word((A), (D) >> 16); \\r
- m68kcontext.write_word((A) + 2, (D) & 0xFFFF);\r
+#define POP_32_F(D) \\r
+ D = m68kcontext.read_long(AREG(7)); \\r
+ AREG(7) += 4;\r
+\r
+#ifndef FAME_BIG_ENDIAN\r
\r
#define FETCH_LONG(A) \\r
(A) = PC[1] | (PC[0] << 16); \\r
PC += 2;\r
\r
- #define PUSH_32_F(D) \\r
- AREG(7) -= 4; \\r
- m68kcontext.write_word(AREG(7), (D) >> 16); \\r
- m68kcontext.write_word(AREG(7) + 2, (D) & 0xFFFF);\r
-\r
- #define POP_32_F(D) \\r
- D = m68kcontext.read_word(AREG(7)) << 16; \\r
- D |= m68kcontext.read_word(AREG(7) + 2) & 0xFFFF; \\r
- AREG(7) += 4;\r
-\r
#define GET_SWORD \\r
(s16)(*PC)\r
\r
\r
#else\r
\r
- #define READ_BYTE_F(A, D) \\r
- D = m68kcontext.read_byte(A) & 0xFF;\r
-\r
- #define READ_WORD_F(A, D) \\r
- D = m68kcontext.read_word(A) & 0xFFFF;\r
-\r
- #define READ_LONG_F(A, D) \\r
- D = m68kcontext.read_long(A);\r
-\r
- #define READSX_LONG_F(A, D) \\r
- D = m68kcontext.read_long(A);\r
-\r
- #define WRITE_LONG_F(A, D) \\r
- m68kcontext.write_long(A, D);\r
-\r
- #define WRITE_LONG_DEC_F(A, D) \\r
- m68kcontext.write_word((A) + 2, (D) >> 16); \\r
- m68kcontext.write_word((A), (D) & 0xFFFF);\r
-\r
#define FETCH_LONG(A) \\r
(A) = PC[0] | (PC[1] << 16); \\r
PC += 2;\r
\r
- #define PUSH_32_F(D) \\r
- AREG(7) -= 4; \\r
- m68kcontext.write_long(AREG(7), D);\r
-\r
- #define POP_32_F(D) \\r
- D = m68kcontext.read_long(AREG(7)); \\r
- AREG(7) += 4;\r
-\r
#define GET_SWORD \\r
((s16)(((*PC & 0xFF) << 8) | (*PC >> 8)))\r
\r
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
PRE_IO
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(12)
}
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
PRE_IO
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(12)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(20)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(20)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(22)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(24)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(26)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(24)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(28)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(24)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(26)
}
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
PRE_IO
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(20)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(20)
}
flag_N = res >> 24;
adr = AREG((Opcode >> 9) & 7) - 4;
AREG((Opcode >> 9) & 7) = adr;
- WRITE_LONG_F(adr, res)
+ WRITE_LONG_DEC_F(adr, res)
POST_IO
RET(22)
}
# settings
-use_fame = 1
+#use_musashi = 1
+#use_mz80 = 1
# profile = 1
# unzip
OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
# CPU cores
-ifeq "$(use_fame)" "1"
-DEFINC += -DEMU_F68K
-OBJS += ../../cpu/fame/famec.o
-else
+ifeq "$(use_musashi)" "1"
DEFINC += -DEMU_M68K
OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o
+else
+DEFINC += -DEMU_F68K
+OBJS += ../../cpu/fame/famec.o
endif
-# mz80
-DEFINC += -D_USE_MZ80
+# z80
+ifeq "$(use_mz80)" "1"
+CFLAGS += -D_USE_MZ80
OBJS += ../../cpu/mz80/mz80.o
+else
+CFLAGS += -D_USE_CZ80
+OBJS += ../../cpu/cz80/cz80.o
+endif
# faked asm
#DEFINC += -D_ASM_DRAW_C
if (fbimg_yoffs < 0) fbimg_yoffs = 0;
fbimg_offs = (fbimg_yoffs*512 + fbimg_xoffs) * 2; // dst is always 16bit
+ /*
lprintf("set_scaling_params:\n");
lprintf("offs: %i, %i\n", fbimg_xoffs, fbimg_yoffs);
lprintf("xy0, xy1: %i, %i; %i, %i\n", g_vertices[0].x, g_vertices[0].y, g_vertices[1].x, g_vertices[1].y);
lprintf("uv0, uv1: %i, %i; %i, %i\n", g_vertices[0].u, g_vertices[0].v, g_vertices[1].u, g_vertices[1].v);
+ */
}
-static void do_slowmode_pal(void)
+static void do_pal_update(int allow_sh)
{
unsigned int *spal=(void *)Pico.cram;
unsigned int *dpal=(void *)localPal;
for (i = 0x3f/2; i >= 0; i--)
dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
- if (Pico.video.reg[0xC]&8) // shadow/hilight?
+ if (allow_sh && (Pico.video.reg[0xC]&8)) // shadow/hilight?
{
// shadowed pixels
for (i = 0x3f/2; i >= 0; i--)
- dpal[0x20|i] = dpal[0x60|i] = (spal[i]>>1)&0x738e738e;
+ dpal[0x20|i] = dpal[0x60|i] = (dpal[i]>>1)&0x738e738e;
// hilighted pixels
for (i = 0x3f; i >= 0; i--) {
int t=localPal[i]&0xe71c;t+=0x4208;
dynamic_palette = 0;
if (Pico.m.dirtyPal)
- do_slowmode_pal();
+ do_pal_update(1);
}
static int EmuScanSlow(unsigned int num, void *sdata)
do_slowmode_lines(num);
dynamic_palette = 1;
}
- do_slowmode_pal();
+ do_pal_update(1);
}
if (dynamic_palette) {
int offs = fbimg_offs;
offs += (psp_screen == VRAM_FB0) ? VRAMOFFS_FB0 : VRAMOFFS_FB1;
- sceKernelDcacheWritebackAll();
-
sceGuSync(0,0); // sync with prev
sceGuStart(GU_DIRECT, guCmdList);
sceGuDrawBuffer(GU_PSM_5650, (void *)offs, 512); // point to back buffer
}
if ((PicoOpt&0x10) && Pico.m.dirtyPal)
- {
- int i, *dpal = (void *)localPal, *spal = (int *)Pico.cram;
- for (i = 0x3f/2; i >= 0; i--)
- dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
- localPal[0xe0] = 0;
- Pico.m.dirtyPal = 0;
- need_pal_upload = 1;
- }
+ do_pal_update(0);
+
+ sceKernelDcacheWritebackAll();
if (need_pal_upload) {
need_pal_upload = 0;
static void sound_end(void)
{
- while (samples_made - samples_done >= samples_block || sceAudioOutput2GetRestSample() > 0)
+ samples_made = samples_done = 0;
+ while (sceAudioOutput2GetRestSample() > 0)
psp_msleep(100);
sceAudio_5C37C0AE();
}
{
sound_thread_exit = 1;
sceKernelSignalSema(sound_sem, 1);
+ sceKernelDeleteSema(sound_sem);
+ sound_sem = -1;
}
static void writeSound(int len)
SRam.changed = 0;
}
- // draw a frame for bg..
- emu_forcedFrame();
+ // clear fps counters and stuff
+ memset32((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4);
}
#define menu_screen psp_screen
static void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
-static void menu_prepare_bg(int use_game_bg);
+static void menu_prepare_bg(int use_game_bg, int use_fg);
static unsigned int inp_prev = 0;
if (pos > 26) break;
if (namelist[i+1]->d_type & DT_DIR) {
smalltext_out16_lim(14, pos*10, "/", 0xd7ff, 1);
- smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xd7ff, 53-3);
+ smalltext_out16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xd7ff, 80-3);
} else {
unsigned short color = file2color(namelist[i+1]->d_name);
- smalltext_out16_lim(14, pos*10, namelist[i+1]->d_name, color, 53-2);
+ smalltext_out16_lim(14, pos*10, namelist[i+1]->d_name, color, 80-2);
}
}
text_out16(5, 130, ">");
}
emu_forcedFrame();
- menu_prepare_bg(1);
+ menu_prepare_bg(1, 0);
restore_oldstate(oldstate);
}
memset32(psp_screen, 0, 512*272*2/4);
emu_forcedFrame();
- menu_prepare_bg(1);
+ menu_prepare_bg(1, 0);
if (oldstate) restore_oldstate(oldstate);
}
}
}
-static void menu_prepare_bg(int use_game_bg)
+static void menu_prepare_bg(int use_game_bg, int use_fg)
{
if (use_game_bg)
{
// darken the active framebuffer
unsigned short *dst = bg_buffer;
- unsigned short *src = psp_screen;
+ unsigned short *src = use_fg ? psp_video_get_active_fb() : psp_screen;
int i;
for (i = 272; i > 0; i--, dst += 480, src += 512)
menu_darken_bg(dst, src, 480, 1);
static void menu_gfx_prepare(void)
{
- menu_prepare_bg(rom_data != NULL);
+ menu_prepare_bg(rom_data != NULL, 1);
menu_draw_begin();
menu_draw_end();