--- hatari/src/uae-cpu/memory.c 2019/04/09 08:49:42 1.1.1.15 +++ hatari/src/uae-cpu/memory.c 2019/04/09 08:54:38 1.1.1.17 @@ -7,11 +7,12 @@ * * Adaptation to Hatari by Thomas Huth * - * This file is distributed under the GNU Public License, version 2 or at - * your option any later version. Read the file gpl.txt for details. + * This file is distributed under the GNU General Public License, version 2 + * or at your option any later version. Read the file gpl.txt for details. */ const char Memory_fileid[] = "Hatari memory.c : " __DATE__ " " __TIME__; +#include #include "config.h" #include "sysdeps.h" #include "hatari-glue.h" @@ -32,6 +33,7 @@ const char Memory_fileid[] = "Hatari mem /* Set illegal_mem to 1 for debug output: */ #define illegal_mem 1 +static int illegal_count = 50; static uae_u32 STmem_size, TTmem_size = 0; static uae_u32 TTmem_mask; @@ -87,11 +89,21 @@ __inline__ void byteput (uaecptr addr, u /* Some prototypes: */ -extern void SDL_Quit(void); static int STmem_check (uaecptr addr, uae_u32 size) REGPARAM; static uae_u8 *STmem_xlate (uaecptr addr) REGPARAM; +static void print_illegal_counted(const char *txt, uaecptr addr) +{ + if (!illegal_mem || illegal_count <= 0) + return; + + write_log("%s at %08lx\n", txt, (long)addr); + if (--illegal_count == 0) + write_log("Suppressing further messages about illegal memory accesses.\n"); +} + + /* A dummy bank that only contains zeros */ static uae_u32 dummy_lget(uaecptr addr) @@ -157,8 +169,7 @@ static uae_u8 *dummy_xlate(uaecptr addr) static uae_u32 BusErrMem_lget(uaecptr addr) { - if (illegal_mem) - write_log ("Bus error lget at %08lx\n", (long)addr); + print_illegal_counted("Bus error lget", addr); M68000_BusError(addr, BUS_ERROR_READ); return 0; @@ -166,8 +177,7 @@ static uae_u32 BusErrMem_lget(uaecptr ad static uae_u32 BusErrMem_wget(uaecptr addr) { - if (illegal_mem) - write_log ("Bus error wget at %08lx\n", (long)addr); + print_illegal_counted("Bus error wget", addr); M68000_BusError(addr, BUS_ERROR_READ); return 0; @@ -175,8 +185,7 @@ static uae_u32 BusErrMem_wget(uaecptr ad static uae_u32 BusErrMem_bget(uaecptr addr) { - if (illegal_mem) - write_log ("Bus error bget at %08lx\n", (long)addr); + print_illegal_counted("Bus error bget", addr); M68000_BusError(addr, BUS_ERROR_READ); return 0; @@ -184,24 +193,21 @@ static uae_u32 BusErrMem_bget(uaecptr ad static void BusErrMem_lput(uaecptr addr, uae_u32 l) { - if (illegal_mem) - write_log ("Bus error lput at %08lx\n", (long)addr); + print_illegal_counted("Bus error lput", addr); M68000_BusError(addr, BUS_ERROR_WRITE); } static void BusErrMem_wput(uaecptr addr, uae_u32 w) { - if (illegal_mem) - write_log ("Bus error wput at %08lx\n", (long)addr); + print_illegal_counted("Bus error wput", addr); M68000_BusError(addr, BUS_ERROR_WRITE); } static void BusErrMem_bput(uaecptr addr, uae_u32 b) { - if (illegal_mem) - write_log ("Bus error bput at %08lx\n", (long)addr); + print_illegal_counted("Bus error bput", addr); M68000_BusError(addr, BUS_ERROR_WRITE); } @@ -380,6 +386,10 @@ static void SysMem_bput(uaecptr addr, ua * **** Void memory **** * Between the ST-RAM end and the 4 MB barrier, there is a void memory space: * Reading always returns the same value and writing does nothing at all. + * [NP] : this is not correct, reading does not always return 0, when there's + * no memory, it will return the latest data that was read on the bus. + * In many cases, this will return the word that was just read in the 68000's + * prefetch register to decode the next opcode (tested on a real STF) */ static uae_u32 VoidMem_lget(uaecptr addr) @@ -514,24 +524,21 @@ static uae_u32 ROMmem_bget(uaecptr addr) static void ROMmem_lput(uaecptr addr, uae_u32 b) { - if (illegal_mem) - write_log ("Illegal ROMmem lput at %08lx\n", (long)addr); + print_illegal_counted("Illegal ROMmem lput", (long)addr); M68000_BusError(addr, BUS_ERROR_WRITE); } static void ROMmem_wput(uaecptr addr, uae_u32 b) { - if (illegal_mem) - write_log ("Illegal ROMmem wput at %08lx\n", (long)addr); + print_illegal_counted("Illegal ROMmem wput", (long)addr); M68000_BusError(addr, BUS_ERROR_WRITE); } static void ROMmem_bput(uaecptr addr, uae_u32 b) { - if (illegal_mem) - write_log ("Illegal ROMmem bput at %08lx\n", (long)addr); + print_illegal_counted("Illegal ROMmem bput", (long)addr); M68000_BusError(addr, BUS_ERROR_WRITE); } @@ -762,6 +769,8 @@ void memory_init(uae_u32 nNewSTMemSize, /* Illegal memory regions cause a bus error on the ST: */ map_banks(&BusErrMem_bank, 0xF10000 >> 16, 0x9); + + illegal_count = 50; }