📄 kick_mcu.c
字号:
/* Auto-generated from kickrun.asm! Do not modify! *//* [kayamon] - had to hack this again, see L0x0e8 and L0x236. * also see L0x0e0. */#include "raine.h"#include "debug.h"#include "ingame.h"UINT8 KSystem_MCU_RDMEM(int a);void KSystem_MCU_WRMEM(int a, UINT8 v);#define MCU_RDMEM(a) KSystem_MCU_RDMEM(a)#define MCU_WRMEM(a,v) KSystem_MCU_WRMEM(a,v)#include "m68705.h"static int unpacked;void KickRun_mcu_reset(void){ m68705.pc = MCU_RDMEM(0x7ff) | (MCU_RDMEM(0x7fe) << 8); m68705.sp = 0x7f; m68705.a = m68705.x = 0x00; m68705.flag_i = 0; m68705.flag_n = m68705.flag_h = m68705.flag_z = m68705.flag_c = 0; unpacked = 0;}/*arghh, fucking msvc, goto jumptables not supported!!! :((*/#if defined(RAINE_DOS) || defined(RAINE_UNIX)#define LABEL(addr) \L0x##addr \#else#define LABEL(addr) \case 0x##addr \#undef JUMP#define JUMP(addr) \break; \#undef JUMP_IMM#define JUMP_IMM(adr) \{ m68705.pc = adr; \break; } \#endifvoid KickRun_mcu(int bih_count){ UINT8 temp; UINT16 addr; UINT8 x = m68705.x; UINT8 a = m68705.a; UINT16 sp = m68705.sp; UINT8 flag_c = m68705.flag_c; UINT8 flag_h = m68705.flag_h; UINT8 flag_n = m68705.flag_n; UINT8 flag_z = m68705.flag_z;#if defined(RAINE_DOS) || defined(RAINE_UNIX) static const M68705_JumpTable jump_table[] = { { 0x080, &&L0x080 }, { 0x09f, &&L0x09f }, { 0x0b4, &&L0x0b4 }, { 0x0d6, &&L0x0d6 }, { 0x0dc, &&L0x0dc }, { 0x0e0, &&L0x0e0 }, { 0x0e2, &&L0x0e2 }, { 0x0e7, &&L0x0e7 }, { 0x0e8, &&L0x0e8 }, { 0x0ea, &&L0x0ea }, { 0x100, &&L0x100 }, { 0x10a, &&L0x10a }, { 0x113, &&L0x113 }, { 0x115, &&L0x115 }, { 0x11d, &&L0x11d }, { 0x126, &&L0x126 }, { 0x128, &&L0x128 }, { 0x12e, &&L0x12e }, { 0x136, &&L0x136 }, { 0x13c, &&L0x13c }, { 0x148, &&L0x148 }, { 0x14e, &&L0x14e }, { 0x15c, &&L0x15c }, { 0x162, &&L0x162 }, { 0x16e, &&L0x16e }, { 0x175, &&L0x175 }, { 0x17c, &&L0x17c }, { 0x183, &&L0x183 }, { 0x186, &&L0x186 }, { 0x194, &&L0x194 }, { 0x19c, &&L0x19c }, { 0x1ac, &&L0x1ac }, { 0x1ae, &&L0x1ae }, { 0x1b8, &&L0x1b8 }, { 0x1c4, &&L0x1c4 }, { 0x1c8, &&L0x1c8 }, { 0x1ca, &&L0x1ca }, { 0x1d4, &&L0x1d4 }, { 0x1e2, &&L0x1e2 }, { 0x1e6, &&L0x1e6 }, { 0x1f8, &&L0x1f8 }, { 0x1fc, &&L0x1fc }, { 0x1fe, &&L0x1fe }, { 0x206, &&L0x206 }, { 0x20e, &&L0x20e }, { 0x216, &&L0x216 }, { 0x21e, &&L0x21e }, { 0x226, &&L0x226 }, { 0x22e, &&L0x22e }, { 0x236, &&L0x236 }, { 0x237, &&L0x237 }, { 0x242, &&L0x242 }, { 0x247, &&L0x247 }, { 0x24c, &&L0x24c }, { 0x251, &&L0x251 }, { 0x254, &&L0x254 }, { 0x25a, &&L0x25a }, { 0x264, &&L0x264 }, { 0x26e, &&L0x26e }, { 0x278, &&L0x278 }, { 0x27c, &&L0x27c }, { 0, NULL } }; if (!unpacked) { M68705_Unpack(&jump_table[0], &&invalid_pc); unpacked=1; }/* code starts here */ JUMP(m68705.pc);#elseLOOP: switch(m68705.pc){#endifLABEL(080): /* lda */ addr = 0x010; a = MCU_RDMEM(0x010); SET_NZ(a);//LABEL(082): /* sta */ SET_NZ(a); MCU_WRMEM(0x000, a);//LABEL(084): /* bclr1 */ BCLR(0x001, 1);//LABEL(086): /* bset1 */ BSET(0x001, 1);//LABEL(088): /* clr */ addr = 0x004; temp = 0; SET_NZ(temp); MCU_WRMEM(addr, temp);//LABEL(08a): /* bset4 */ BSET(0x001, 4);//LABEL(08c): /* bclr3 */ BCLR(0x001, 3);//LABEL(08e): /* bclr0 */ BCLR(0x001, 0);//LABEL(090): /* lda */ addr = 0x000; a = MCU_RDMEM(0x000); SET_NZ(a);//LABEL(092): /* bset3 */ BSET(0x001, 3);//LABEL(094): /* bset0 */ BSET(0x001, 0);//LABEL(096): /* sta */ SET_NZ(a); MCU_WRMEM(0x015, a);//LABEL(098): /* lda */ a = 0x0ff; SET_NZ(a);//LABEL(09a): /* sta */ SET_NZ(a); MCU_WRMEM(0x004, a);//LABEL(09c): /* lda */ addr = 0x015; a = MCU_RDMEM(0x015); SET_NZ(a);//LABEL(09e): /* rts */ PULLWORD(m68705.pc); JUMP(m68705.pc);LABEL(09f): /* sta */ SET_NZ(a); MCU_WRMEM(0x015, a);//LABEL(0a1): /* lda */ addr = 0x011; a = MCU_RDMEM(0x011); SET_NZ(a);//LABEL(0a3): /* sta */ SET_NZ(a); MCU_WRMEM(0x000, a);//LABEL(0a5): /* bclr1 */ BCLR(0x001, 1);//LABEL(0a7): /* bset1 */ BSET(0x001, 1);//LABEL(0a9): /* lda */ addr = 0x015; a = MCU_RDMEM(0x015); SET_NZ(a);//LABEL(0ab): /* sta */ SET_NZ(a); MCU_WRMEM(0x000, a);//LABEL(0ad): /* bclr4 */ BCLR(0x001, 4);//LABEL(0af): /* bclr3 */ BCLR(0x001, 3);//LABEL(0b1): /* bset3 */ BSET(0x001, 3);//LABEL(0b3): /* rts */ PULLWORD(m68705.pc); JUMP(m68705.pc);LABEL(0b4): /* sei *///INIT_PC m68705.flag_i = 1;//LABEL(0b5): /* rsp */ sp = 0x7f;//LABEL(0b6): /* lda */ a = 0x0ff; SET_NZ(a);//LABEL(0b8): /* sta */ SET_NZ(a); MCU_WRMEM(0x004, a);//LABEL(0ba): /* lda */ a = 0x000; SET_NZ(a);//LABEL(0bc): /* sta */ SET_NZ(a); MCU_WRMEM(0x006, a);//LABEL(0be): /* lda */ a = 0x0df; SET_NZ(a);//LABEL(0c0): /* sta */ SET_NZ(a); MCU_WRMEM(0x001, a);//LABEL(0c2): /* lda */ a = 0x0ff; SET_NZ(a);//LABEL(0c4): /* sta */ SET_NZ(a); MCU_WRMEM(0x005, a);//LABEL(0c6): /* lda */ a = 0x0df; SET_NZ(a);//LABEL(0c8): /* sta */ SET_NZ(a); MCU_WRMEM(0x001, a);//LABEL(0ca): /* clr */ addr = 0x014; temp = 0; SET_NZ(temp); MCU_WRMEM(addr, temp);//LABEL(0cc): /* bset2 */ BSET(0x001, 2);//LABEL(0ce): /* lda */ a = 0x00d; SET_NZ(a);//LABEL(0d0): /* sta */ SET_NZ(a); MCU_WRMEM(0x011, a);//LABEL(0d2): /* lda */ a = 0x0ff; SET_NZ(a);//LABEL(0d4): /* jsr */ PUSHWORD(0x0d6); JUMP_IMM(0x09f);LABEL(0d6): /* inc */ addr = 0x011; INC(temp, MCU_RDMEM(0x011)); MCU_WRMEM(addr, temp);//LABEL(0d8): /* lda */ a = 0x0ff; SET_NZ(a);//LABEL(0da): /* jsr */ PUSHWORD(0x0dc); JUMP_IMM(0x09f);LABEL(0dc): /* lda */ a = 0x07f; SET_NZ(a);//LABEL(0de): /* sta */ SET_NZ(a); MCU_WRMEM(0x010, a);LABEL(0e0): /* jsr */ PUSHWORD(0x0e2); JUMP_IMM(0x080);LABEL(0e2): /* sta */ SET_NZ(a); MCU_WRMEM(0x018, a);//LABEL(0e4): /* brclr7 */ //BRCLR(0x018, 7) //JUMP_IMM(0x0e0); /* [kayamon] - hacked here to yield itself, otherwise it'd never pass the startup handshake */ BRSET(0x018, 7) JUMP_IMM(0x0e7); /* switch to jump on inverse case */ m68705.pc = 0x0e0; m68705.x = x; m68705.a = a; m68705.sp = sp; m68705.flag_c = flag_c; m68705.flag_h = flag_h; m68705.flag_n = flag_n; m68705.flag_z = flag_z; return;LABEL(0e7): /* cli */ m68705.flag_i = 0;LABEL(0e8): /* jmp */ // [kayamon] - fall-through here to interrupt code //JUMP_IMM(0x0e8);LABEL(0ea): /* bset5 */ BSET(0x001, 5);//LABEL(0ec): /* bclr5 */ BCLR(0x001, 5);//LABEL(0ee): /* lda */ a = 0x047; SET_NZ(a);//LABEL(0f0): /* sta */ SET_NZ(a); MCU_WRMEM(0x011, a);//LABEL(0f2): /* lda */ addr = 0x002; a = MCU_RDMEM(0x002); SET_NZ(a);//LABEL(0f4): /* anda */ AND(a, a, 0x03f); SET_NZ(a);//LABEL(0f6): /* eora */ EOR(a, a, 0x003); SET_NZ(a);//LABEL(0f8): /* sta */ SET_NZ(a); MCU_WRMEM(0x012, a);//LABEL(0fa): /* bset2 */ BSET(0x001, 2);//LABEL(0fc): /* lda */ addr = 0x012; a = MCU_RDMEM(0x012); SET_NZ(a);//LABEL(0fe): /* jsr */ PUSHWORD(0x100); JUMP_IMM(0x09f);LABEL(100): /* clr */ addr = 0x010; temp = 0; SET_NZ(temp); MCU_WRMEM(addr, temp);//LABEL(102): /* lda */ a = 0x00d; SET_NZ(a);//LABEL(104): /* sta */ SET_NZ(a); MCU_WRMEM(0x011, a);//LABEL(106): /* bclr2 */ BCLR(0x001, 2);//LABEL(108): /* jsr */ PUSHWORD(0x10a); JUMP_IMM(0x080);LABEL(10a): /* sta */ SET_NZ(a); MCU_WRMEM(0x012, a);//LABEL(10c): /* bset2 */ BSET(0x001, 2);//LABEL(10e): /* lda */ addr = 0x012; a = MCU_RDMEM(0x012); SET_NZ(a);//LABEL(110): /* jsr */ PUSHWORD(0x113); JUMP_IMM(0x237);LABEL(113): /* jsr */ PUSHWORD(0x115); JUMP_IMM(0x09f);LABEL(115): /* inc */ addr = 0x010; INC(temp, MCU_RDMEM(0x010)); MCU_WRMEM(addr, temp);//LABEL(117): /* inc */ addr = 0x011; INC(temp, MCU_RDMEM(0x011)); MCU_WRMEM(addr, temp);//LABEL(119): /* bclr2 */ BCLR(0x001, 2);//LABEL(11b): /* jsr */ PUSHWORD(0x11d); JUMP_IMM(0x080);LABEL(11d): /* sta */ SET_NZ(a); MCU_WRMEM(0x012, a);//LABEL(11f): /* bset2 */ BSET(0x001, 2);//LABEL(121): /* lda */ addr = 0x012; a = MCU_RDMEM(0x012); SET_NZ(a);//LABEL(123): /* jsr */ PUSHWORD(0x126); JUMP_IMM(0x237);LABEL(126): /* jsr */ PUSHWORD(0x128); JUMP_IMM(0x09f);LABEL(128): /* lda */ a = 0x06b; SET_NZ(a);//LABEL(12a): /* sta */ SET_NZ(a); MCU_WRMEM(0x010, a);//LABEL(12c): /* jsr */ PUSHWORD(0x12e); JUMP_IMM(0x080);LABEL(12e): /* sta */ SET_NZ(a); MCU_WRMEM(0x017, a);//LABEL(130): /* lda */ a = 0x06c; SET_NZ(a);//LABEL(132): /* sta */ SET_NZ(a); MCU_WRMEM(0x010, a);//LABEL(134): /* jsr */ PUSHWORD(0x136); JUMP_IMM(0x080);LABEL(136): /* eora */ EOR(a, a, 0x020); SET_NZ(a);//LABEL(138): /* bne */ IF_CC_NZ() JUMP_IMM(0x13c);//LABEL(13a): /* clr */ addr = 0x017; temp = 0; SET_NZ(temp); MCU_WRMEM(addr, temp);LABEL(13c): /* lda */ addr = 0x017; a = MCU_RDMEM(0x017); SET_NZ(a);//LABEL(13e): /* eora */ EOR(a, a, 0x0ff); SET_NZ(a);//LABEL(140): /* beq */ IF_CC_Z() JUMP_IMM(0x148);//LABEL(142): /* lda */ addr = 0x014; a = MCU_RDMEM(0x014); SET_NZ(a);//LABEL(144): /* beq */ IF_CC_Z() JUMP_IMM(0x148);//LABEL(146): /* dec */ addr = 0x014; DEC(temp, MCU_RDMEM(0x014)); MCU_WRMEM(addr, temp);LABEL(148): /* lda */ a = 0x06d; SET_NZ(a);//LABEL(14a): /* sta */ SET_NZ(a); MCU_WRMEM(0x010, a);//LABEL(14c): /* jsr */ PUSHWORD(0x14e); JUMP_IMM(0x080);LABEL(14e): /* sta */ SET_NZ(a); MCU_WRMEM(0x013, a);//LABEL(150): /* brset6 */ BRSET(0x013, 6) JUMP_IMM(0x15c);//LABEL(153): /* brclr7 */ BRCLR(0x013, 7) JUMP_IMM(0x15c);//LABEL(156): /* lda */ addr = 0x014; a = MCU_RDMEM(0x014); SET_NZ(a);//LABEL(158): /* bne */ IF_CC_NZ() JUMP_IMM(0x15c);//LABEL(15a): /* bra */ JUMP_IMM(0x186);LABEL(15c): /* lda */ a = 0x068; SET_NZ(a);//LABEL(15e): /* sta */ SET_NZ(a);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -