Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
vinriviere committed Apr 9, 2016
2 parents 1897e62 + 6a789a3 commit 6a0cfaf
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 6 deletions.
66 changes: 66 additions & 0 deletions 68kemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,72 @@ void m68ki_hook_trap14()
m68k_set_reg(M68K_REG_D0, (int)reg_d0);
}

void m68ki_hook_linea()
{
unsigned short* pc = (unsigned short *)m68k_get_reg(NULL, M68K_REG_PC);
unsigned short* sp = (unsigned short *)m68k_get_reg(NULL, M68K_REG_SP);
register long reg_d0 __asm__("d0");
register long reg_a0 __asm__("a0");
register long reg_a1 __asm__("a1");
register long reg_a2 __asm__("a2");
unsigned short opcode = pc[-1];
unsigned short num = opcode & 0x000f;

//printf("Line A %u 0x%04x\n", num, opcode);

__asm__ volatile
(
"move.l sp,a3\n\t"
"move.l %4,sp\n\t"
"moveq #0,d0\n\t"
"move.w %5,d0\n\t"
"lsl.l #2,d0\n\t"
"jmp 0f(pc,d0.l)\n\t"
"0:\n\t"
".dc.w 0xa920\n\t"
"bra.s 1f\n\t"
".dc.w 0xa921\n\t"
"bra.s 1f\n\t"
".dc.w 0xa922\n\t"
"bra.s 1f\n\t"
".dc.w 0xa923\n\t"
"bra.s 1f\n\t"
".dc.w 0xa924\n\t"
"bra.s 1f\n\t"
".dc.w 0xa925\n\t"
"bra.s 1f\n\t"
".dc.w 0xa926\n\t"
"bra.s 1f\n\t"
".dc.w 0xa927\n\t"
"bra.s 1f\n\t"
".dc.w 0xa928\n\t"
"bra.s 1f\n\t"
".dc.w 0xa929\n\t"
"bra.s 1f\n\t"
".dc.w 0xa92a\n\t"
"bra.s 1f\n\t"
".dc.w 0xa92b\n\t"
"bra.s 1f\n\t"
".dc.w 0xa92c\n\t"
"bra.s 1f\n\t"
".dc.w 0xa92d\n\t"
"bra.s 1f\n\t"
".dc.w 0xa92e\n\t"
"bra.s 1f\n\t"
".dc.w 0xa92f\n\t"
"1:\n\t"
"move.l a3,sp"
: "=r"(reg_d0), "=r"(reg_a0), "=r"(reg_a1), "=r"(reg_a2) /* outputs */
: "g"(sp), "g"(num)
: "d1", "d2", "a3", "memory" /* clobbered regs */
);

m68k_set_reg(M68K_REG_D0, (int)reg_d0);
m68k_set_reg(M68K_REG_A0, (int)reg_a0);
m68k_set_reg(M68K_REG_A1, (int)reg_a1);
m68k_set_reg(M68K_REG_A2, (int)reg_a2);
}

static int int_ack_callback_vector = M68K_INT_ACK_AUTOVECTOR;

// Exception vector callback
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ musashi.stamp:
cd musashi && $(MAKE) libmusashi.a
touch $@

$(TARGET): musashi.stamp $(OBJS)
$(TARGET): musashi.stamp $(OBJS) $(LIBS)
$(CC) $(CPUFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@

.PHONY = clean
Expand Down
4 changes: 3 additions & 1 deletion asm.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.cpu 68020
.cpu 68000

// 0(sp).l = ret pc
// 4(sp).w = 0x26
Expand Down Expand Up @@ -48,5 +48,7 @@ super:
endf:
movem.l (sp)+,d3-d7/a3-a6
rts
/*
format:
.asciz "a0 = 0x%08lx\n"
*/
5 changes: 4 additions & 1 deletion musashi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ clean:
rm -f $(filter-out Makefile musashi.patch, $(wildcard *))

# Dependencies
m68kcpu.c: m68kops.h
m68kcpu.o: m68kops.h m68kcpu.h
m68kopac.o: m68kcpu.h
m68kopdm.o: m68kcpu.h
m68kopnz.o: m68kcpu.h
24 changes: 21 additions & 3 deletions musashi/musashi.patch
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ diff -aurN musashi.orig/m68kcpu.c musashi/m68kcpu.c
}

/* Pulse the HALT line on the CPU */
diff -aurN musashi.orig/m68kcpu.h musashi/m68kcpu.h
--- musashi.orig/m68kcpu.h 2012-03-13 00:17:02.628375000 +0100
+++ musashi/m68kcpu.h 2012-03-13 00:18:19.003375000 +0100
--- musashi.orig/m68kcpu.h 2001-01-30 09:49:24.000000000 +0100
+++ musashi/m68kcpu.h 2012-03-14 01:45:21.187500000 +0100
@@ -1646,12 +1646,35 @@
/* Trap#n stacks a 0 frame but behaves like group2 otherwise */
INLINE void m68ki_exception_trapN(uint vector)
Expand Down Expand Up @@ -103,3 +102,22 @@ diff -aurN musashi.orig/m68kcpu.h musashi/m68kcpu.h
}

/* Exception for trace mode */
@@ -1687,6 +1710,10 @@
/* Exception for A-Line instructions */
INLINE void m68ki_exception_1010(void)
{
+ extern void m68ki_hook_linea();
+ m68ki_hook_linea();
+#if 0
+ }
uint sr;
#if M68K_LOG_1010_1111 == OPT_ON
M68K_DO_LOG_EMU((M68K_LOG_FILEHANDLE "%s at %08x: called 1010 instruction %04x (%s)\n",
@@ -1700,6 +1727,7 @@

/* Use up some clock cycles and undo the instruction's cycles */
USE_CYCLES(CYC_EXCEPTION[EXCEPTION_1010] - CYC_INSTRUCTION[REG_IR]);
+#endif
}

/* Exception for F-Line instructions */

0 comments on commit 6a0cfaf

Please sign in to comment.