diff --git a/68kemu.c b/68kemu.c index e0dbb3a..72fdf4a 100644 --- a/68kemu.c +++ b/68kemu.c @@ -1,3 +1,20 @@ +/* + 68kemu.c + Written in 2010-2012 by Vincent Riviere + + This file is part of: + 68Kemu - A CPU emulator for Atari TOS computers + http://vincent.riviere.free.fr/soft/68kemu/ + + To the extent possible under law, the author(s) have dedicated all copyright + and related and neighboring rights to this software to the public domain + worldwide. This software is distributed without any warranty. + + You should have received a copy of the CC0 Public Domain Dedication along + with this software. + If not, see . +*/ + #include #include #include @@ -10,131 +27,131 @@ static void* old_ssp_real; static void* BothSuperFromUser(void* new_ssp_emu) { - unsigned short sr; - void* old_ssp_emu; + unsigned short sr; + void* old_ssp_emu; - // Switch the real CPU to supervisor mode - old_ssp_real = (void *)Super(SUP_SET); + // Switch the real CPU to supervisor mode + old_ssp_real = (void *)Super(SUP_SET); - // Switch the emulated CPU to supervisor mode - if (new_ssp_emu == NULL) - new_ssp_emu = (void*)m68k_get_reg(NULL, M68K_REG_SP); + // Switch the emulated CPU to supervisor mode + if (new_ssp_emu == NULL) + new_ssp_emu = (void*)m68k_get_reg(NULL, M68K_REG_SP); - sr = (unsigned short)m68k_get_reg(NULL, M68K_REG_SR); - sr |= 0x2000; - m68k_set_reg(M68K_REG_SR, sr); + sr = (unsigned short)m68k_get_reg(NULL, M68K_REG_SR); + sr |= 0x2000; + m68k_set_reg(M68K_REG_SR, sr); - old_ssp_emu = (void*)m68k_get_reg(NULL, M68K_REG_SP); - m68k_set_reg(M68K_REG_SP, (int)new_ssp_emu); - m68k_set_reg(M68K_REG_D0, (int)old_ssp_emu); - - return old_ssp_emu; + old_ssp_emu = (void*)m68k_get_reg(NULL, M68K_REG_SP); + m68k_set_reg(M68K_REG_SP, (int)new_ssp_emu); + m68k_set_reg(M68K_REG_D0, (int)old_ssp_emu); + + return old_ssp_emu; } static void BothSuperToUser(void* old_ssp_emu) { - unsigned short sr; + unsigned short sr; - // Switch the real CPU to user mode - SuperToUser(old_ssp_real); + // Switch the real CPU to user mode + SuperToUser(old_ssp_real); - m68k_set_reg(M68K_REG_SP, (int)old_ssp_emu); + m68k_set_reg(M68K_REG_SP, (int)old_ssp_emu); - sr = (unsigned short)m68k_get_reg(NULL, M68K_REG_SR); - sr &= ~0x2000; - m68k_set_reg(M68K_REG_SR, sr); + sr = (unsigned short)m68k_get_reg(NULL, M68K_REG_SR); + sr &= ~0x2000; + m68k_set_reg(M68K_REG_SR, sr); - m68k_set_reg(M68K_REG_D0, (int)0); + m68k_set_reg(M68K_REG_D0, (int)0); } void m68ki_hook_trap1() { - unsigned short* sp = (unsigned short *)m68k_get_reg(NULL, M68K_REG_SP); - unsigned short num = *sp; - - //printf("GEMDOS(0x%02x)\n", num); - - if (num == 0x20) - { - void* param = *(void**)(sp + 1); - //printf("Super(0x%08lx)\n", (long)param); - - if (param != (void*)1) - { - long current_super = Super(SUP_INQUIRE); - if (current_super) - { - BothSuperToUser(param); - return; - } - else /* current user */ - { - BothSuperFromUser(param); - return; - } - } - } - - // Standard block - { - register long reg_d0 __asm__("d0"); - - __asm__ volatile - ( - "move.l sp,a3\n\t" - "move.l %1,sp\n\t" - "trap #1\n\t" - "move.l a3,sp" - : "=r"(reg_d0) /* outputs */ - : "g"(sp) - : "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ - ); - - m68k_set_reg(M68K_REG_D0, (int)reg_d0); - } + unsigned short* sp = (unsigned short *)m68k_get_reg(NULL, M68K_REG_SP); + unsigned short num = *sp; + + //printf("GEMDOS(0x%02x)\n", num); + + if (num == 0x20) + { + void* param = *(void**)(sp + 1); + //printf("Super(0x%08lx)\n", (long)param); + + if (param != (void*)1) + { + long current_super = Super(SUP_INQUIRE); + if (current_super) + { + BothSuperToUser(param); + return; + } + else /* current user */ + { + BothSuperFromUser(param); + return; + } + } + } + + // Standard block + { + register long reg_d0 __asm__("d0"); + + __asm__ volatile + ( + "move.l sp,a3\n\t" + "move.l %1,sp\n\t" + "trap #1\n\t" + "move.l a3,sp" + : "=r"(reg_d0) /* outputs */ + : "g"(sp) + : "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ + ); + + m68k_set_reg(M68K_REG_D0, (int)reg_d0); + } } void m68ki_hook_trap2() { - void* sp = (void*)m68k_get_reg(NULL, M68K_REG_SP); - unsigned long ad0 = (unsigned long)m68k_get_reg(NULL, M68K_REG_D0); - unsigned long ad1 = (unsigned long)m68k_get_reg(NULL, M68K_REG_D1); - - //printf("GEM\n"); - __asm__ volatile - ( - "move.l sp,a3\n\t" - "move.l %1,d0\n\t" - "move.l %2,d1\n\t" - "move.l %0,sp\n\t" - "trap #2\n\t" - "move.l a3,sp" - : /* outputs */ - : "g"(sp), "g"(ad0), "g"(ad1) - : "d0", "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ - ); + void* sp = (void*)m68k_get_reg(NULL, M68K_REG_SP); + unsigned long ad0 = (unsigned long)m68k_get_reg(NULL, M68K_REG_D0); + unsigned long ad1 = (unsigned long)m68k_get_reg(NULL, M68K_REG_D1); + + //printf("GEM\n"); + __asm__ volatile + ( + "move.l sp,a3\n\t" + "move.l %1,d0\n\t" + "move.l %2,d1\n\t" + "move.l %0,sp\n\t" + "trap #2\n\t" + "move.l a3,sp" + : /* outputs */ + : "g"(sp), "g"(ad0), "g"(ad1) + : "d0", "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ + ); } void m68ki_hook_trap13() { - unsigned short* sp = (unsigned short *)m68k_get_reg(NULL, M68K_REG_SP); - //unsigned short num = *sp; - register long reg_d0 __asm__("d0"); - - //printf("BIOS(0x%02x)\n", num); - - __asm__ volatile - ( - "move.l sp,a3\n\t" - "move.l %1,sp\n\t" - "trap #13\n\t" - "move.l a3,sp" - : "=r"(reg_d0) /* outputs */ - : "g"(sp) - : "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ - ); - - m68k_set_reg(M68K_REG_D0, (int)reg_d0); + unsigned short* sp = (unsigned short *)m68k_get_reg(NULL, M68K_REG_SP); + //unsigned short num = *sp; + register long reg_d0 __asm__("d0"); + + //printf("BIOS(0x%02x)\n", num); + + __asm__ volatile + ( + "move.l sp,a3\n\t" + "move.l %1,sp\n\t" + "trap #13\n\t" + "move.l a3,sp" + : "=r"(reg_d0) /* outputs */ + : "g"(sp) + : "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ + ); + + m68k_set_reg(M68K_REG_D0, (int)reg_d0); } typedef void VOIDFUNC(void); @@ -144,10 +161,10 @@ VOIDFUNC* nextCallback = NULL; // This callback is called from the real CPU void generic_callback(void) { - if (nextCallback == NULL) - abort(); + if (nextCallback == NULL) + abort(); - // TODO + // TODO } */ @@ -156,7 +173,7 @@ typedef unsigned long SUPEXEC_TYPE(SUPEXEC_CALLBACK_TYPE* f); /* static unsigned long RunEmulatedFunction(SUPEXEC_TYPE* f, SUPEXEC_CALLBACK_TYPE* param) { - return f(param); + return f(param); } */ //unsigned long SupexecImpl(SUPEXEC_CALLBACK_TYPE* f); @@ -166,129 +183,129 @@ void SupexecImpl(void); // This function is run on the emulated CPU unsigned long SupexecImpl(SUPEXEC_CALLBACK_TYPE* f) { - long from_super = SuperInquire(); - void* old_ssp; - unsigned long ret; + long from_super = SuperInquire(); + void* old_ssp; + unsigned long ret; - if (!from_super) - old_ssp = SuperFromUser(); + if (!from_super) + old_ssp = SuperFromUser(); - ret = f(); + ret = f(); - if (!from_super) - SuperToUser(old_ssp); - - return ret; + if (!from_super) + SuperToUser(old_ssp); + + return ret; } */ void m68ki_hook_trap14() { - unsigned char* sp = (unsigned char *)m68k_get_reg(NULL, M68K_REG_SP); - unsigned short num = *(unsigned short*)sp; - register long reg_d0 __asm__("d0"); - - //printf("XBIOS(0x%02x)\n", num); - - if (num == 0x26) - { - //SUPEXEC_CALLBACK_TYPE* pCallback = *(SUPEXEC_CALLBACK_TYPE**)(sp + 2); - //unsigned long ret; - unsigned long* sp; - void* pc; - - //printf("Supexec(0x%08lx)\n", (unsigned long)pCallback); - //ret = RunEmulatedFunction(SupexecImpl, pCallback); - //m68k_set_reg(M68K_REG_D0, (int)ret); - pc = (void*)m68k_get_reg(NULL, M68K_REG_PC); - //printf("*pc = 0x%04x\n", *(((unsigned short*)pc)-1)); - //return; - sp = (unsigned long*)m68k_get_reg(NULL, M68K_REG_SP); - *--sp = (unsigned long)pc; - m68k_set_reg(M68K_REG_SP, (int)sp); - m68k_set_reg(M68K_REG_PC, (int)SupexecImpl); - return; - } - - __asm__ volatile - ( - "move.l sp,a3\n\t" - "move.l %1,sp\n\t" - "trap #14\n\t" - "move.l a3,sp" - : "=r"(reg_d0) /* outputs */ - : "g"(sp) - : "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ - ); - - //nextCallback = NULL; - - m68k_set_reg(M68K_REG_D0, (int)reg_d0); + unsigned char* sp = (unsigned char *)m68k_get_reg(NULL, M68K_REG_SP); + unsigned short num = *(unsigned short*)sp; + register long reg_d0 __asm__("d0"); + + //printf("XBIOS(0x%02x)\n", num); + + if (num == 0x26) + { + //SUPEXEC_CALLBACK_TYPE* pCallback = *(SUPEXEC_CALLBACK_TYPE**)(sp + 2); + //unsigned long ret; + unsigned long* sp; + void* pc; + + //printf("Supexec(0x%08lx)\n", (unsigned long)pCallback); + //ret = RunEmulatedFunction(SupexecImpl, pCallback); + //m68k_set_reg(M68K_REG_D0, (int)ret); + pc = (void*)m68k_get_reg(NULL, M68K_REG_PC); + //printf("*pc = 0x%04x\n", *(((unsigned short*)pc)-1)); + //return; + sp = (unsigned long*)m68k_get_reg(NULL, M68K_REG_SP); + *--sp = (unsigned long)pc; + m68k_set_reg(M68K_REG_SP, (int)sp); + m68k_set_reg(M68K_REG_PC, (int)SupexecImpl); + return; + } + + __asm__ volatile + ( + "move.l sp,a3\n\t" + "move.l %1,sp\n\t" + "trap #14\n\t" + "move.l a3,sp" + : "=r"(reg_d0) /* outputs */ + : "g"(sp) + : "d1", "d2", "a0", "a1", "a2", "a3", "memory" /* clobbered regs */ + ); + + //nextCallback = NULL; + + 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); + 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; @@ -296,64 +313,80 @@ static int int_ack_callback_vector = M68K_INT_ACK_AUTOVECTOR; // Exception vector callback int int_ack_callback(int int_level) { - return int_ack_callback_vector; + return int_ack_callback_vector; } unsigned char systack[64*1024]; void buildCommandTail(char tail[128], char* argv[], int argc) { - int i; - - tail[1] = '\0'; - for (i = 0; i < argc; ++i) - { - if (i > 0) - strcat(tail + 1, " "); - - strcat(tail + 1, argv[i]); - } - - tail[0] = (char)strlen(tail + 1); + int i; + + tail[1] = '\0'; + for (i = 0; i < argc; ++i) + { + if (i > 0) + strcat(tail + 1, " "); + + strcat(tail + 1, argv[i]); + } + + tail[0] = (char)strlen(tail + 1); } int main(int argc, char* argv[]) { - BASEPAGE* bp; - unsigned long* pStack; - - if (argc < 2) - { - fprintf(stderr, "usage: %s [arguments...]\n", argv[0]); - return 1; - } - - char tail[128]; - buildCommandTail(tail, argv + 2, argc - 2); - bp = (BASEPAGE*)Pexec(PE_LOAD, argv[1], tail, NULL); - if ((long)bp < 0) - { - fprintf(stderr, "error: cannot load %s.\n", argv[1]); - return 1; - } - - m68k_set_cpu_type(M68K_CPU_TYPE_68020); - m68k_pulse_reset(); // Patched - //m68k_set_int_ack_callback(int_ack_callback); - - pStack = (unsigned long*)bp->p_hitpa; - *--pStack = (unsigned long)bp; - *--pStack = (unsigned long)0; - - m68k_set_reg(M68K_REG_SP, (int)(systack + 1)); - m68k_set_reg(M68K_REG_SR, 0x0300); - m68k_set_reg(M68K_REG_SP, (int)pStack); - m68k_set_reg(M68K_REG_PC, (int)bp->p_tbase); - - for (;;) - { - m68k_execute(10000); - } - - return 0; + BASEPAGE* bp; + unsigned long* pStack; + + if (argc < 2) + { + fprintf(stderr, "usage: %s [arguments...]\n", argv[0]); + + fputs( + "\033E" // Clear screen + "68Kemu 20120317 ALPHA - A CPU emulator for Atari TOS computers\n" + "Homepage: http://vincent.riviere.free.fr/soft/68kemu/\n" + "Written in 2010-2012 by Vincent Riviere \n" + "\n" + "Based on the Musashi M680x0 emulator Copyright 1998-2001 Karl Stenerud.\n" + "Usage and redistribution are free for any non-commercial purpose.\n" + "Please contact the authors for commercial usage and redistribution.\n" + "\n" + "Press any key.\n" + , stderr); + + Cnecin(); + + return 1; + } + + char tail[128]; + buildCommandTail(tail, argv + 2, argc - 2); + bp = (BASEPAGE*)Pexec(PE_LOAD, argv[1], tail, NULL); + if ((long)bp < 0) + { + fprintf(stderr, "error: cannot load %s.\n", argv[1]); + return 1; + } + + m68k_set_cpu_type(M68K_CPU_TYPE_68020); + m68k_pulse_reset(); // Patched + //m68k_set_int_ack_callback(int_ack_callback); + + pStack = (unsigned long*)bp->p_hitpa; + *--pStack = (unsigned long)bp; + *--pStack = (unsigned long)0; + + m68k_set_reg(M68K_REG_SP, (int)(systack + 1)); + m68k_set_reg(M68K_REG_SR, 0x0300); + m68k_set_reg(M68K_REG_SP, (int)pStack); + m68k_set_reg(M68K_REG_PC, (int)bp->p_tbase); + + for (;;) + { + m68k_execute(10000); + } + + return 0; } diff --git a/COPYING.txt b/COPYING.txt new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/COPYING.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/Makefile b/Makefile index 81cf101..81f52ff 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,24 @@ +# Makefile +# Written in 2010-2012 by Vincent Riviere +# +# This file is part of: +# 68Kemu - A CPU emulator for Atari TOS computers +# http://vincent.riviere.free.fr/soft/68kemu/ +# +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication along +# with this software. +# If not, see . + CC = m68k-atari-mint-gcc CPUFLAGS = -mcpu=5475 CFLAGS = -Wall -O3 -fomit-frame-pointer LDFLAGS = -s LIBS = musashi/libmusashi.a -INCLUDES = -Imusashi TARGET = 68kemu.prg OBJS = 68kemu.o asm.o diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..2b38eb2 --- /dev/null +++ b/README.txt @@ -0,0 +1,31 @@ +68Kemu - A CPU emulator for Atari TOS computers +Written in 2010-2012 by Vincent Riviere +http://vincent.riviere.free.fr/soft/68kemu/ + +* Description + +This software allows running 68020 TOS programs on a TOS computer featuring a +different physical CPU, such as 68000 or ColdFire. +While the target program itself runs with the emulated CPU, the systems calls +are redirected to the underlying OS where they run natively. +This provides optimal speed and compatibility. + +* License + +- Usage of 68Kemu binaries is free for any purpose. + +- Redistribution of the binaries is allowed for any non-commercial purpose + It would also be nice to redistribute the sources, but this is not mandatory. + +- Redistribution in commercial environment is restricted, as stated by the + Musashi license. + +- The 68Kemu main sources are distributed under the CC0 license. Basically, + this means you are allowed to do anything with them, including reusing them + in your own software with any license, in source or binary form, for money + or for free. See COPYING.txt for license details. + +- 68Kemu uses the Musashi M680x0 emulator as back-end, which is Copyright + Karl Stenerud. Basically, it is free for any non-commercial purpose, but + restrictions apply in commercial environments. + See musashi/readme.txt for details. diff --git a/asm.S b/asm.S index 89f899c..a9de236 100644 --- a/asm.S +++ b/asm.S @@ -1,4 +1,25 @@ - .cpu 68000 +/* + asm.S + Written in 2010-2012 by Vincent Riviere + + This file is part of: + 68Kemu - A CPU emulator for Atari TOS computers + http://vincent.riviere.free.fr/soft/68kemu/ + + To the extent possible under law, the author(s) have dedicated all copyright + and related and neighboring rights to this software to the public domain + worldwide. This software is distributed without any warranty. + + You should have received a copy of the CC0 Public Domain Dedication along + with this software. + If not, see . +*/ + +/* + This file contains code which will run on the emulated CPU. +*/ + + .cpu 68000 // 0(sp).l = ret pc // 4(sp).w = 0x26 diff --git a/m68kinl.h b/m68kinl.h index fd4234f..48e5fe3 100644 --- a/m68kinl.h +++ b/m68kinl.h @@ -1,3 +1,20 @@ +/* + m68kinl.h + Written in 2010-2012 by Vincent Riviere + + This file is part of: + 68Kemu - A CPU emulator for Atari TOS computers + http://vincent.riviere.free.fr/soft/68kemu/ + + To the extent possible under law, the author(s) have dedicated all copyright + and related and neighboring rights to this software to the public domain + worldwide. This software is distributed without any warranty. + + You should have received a copy of the CC0 Public Domain Dedication along + with this software. + If not, see . +*/ + #ifndef __INC_M68KINL_H__ #define __INC_M68KINL_H__ diff --git a/musashi/Makefile b/musashi/Makefile index f4b9ccd..e1d04dd 100644 --- a/musashi/Makefile +++ b/musashi/Makefile @@ -1,3 +1,23 @@ +# musashi/Makefile +# Written in 2010-2012 by Vincent Riviere +# +# This file is part of: +# 68Kemu - A CPU emulator for Atari TOS computers +# http://vincent.riviere.free.fr/soft/68kemu/ +# +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication along +# with this software. +# If not, see . + +# Warning: The purpose of this Makefile is to build the Musashi CPU emulator, +# which is Copyright 1998-2001 Karl Stenerud and provided with its own license. +# There are restrictions for using and redistributing Musashi. +# See readme.txt in 3rd-party/musashi-3.3.1/musashi331.zip for details. + CC = m68k-atari-mint-gcc CPUFLAGS = -mcpu=5475 CFLAGS = -Wall -O3 -fomit-frame-pointer