diff --git a/core/core.mk b/core/core.mk index e3be6084d..de52efa21 100755 --- a/core/core.mk +++ b/core/core.mk @@ -8,8 +8,8 @@ RZDCY_SRC_DIR ?= $(call my-dir) RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \ hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ plugins/ profiler/ oslib/ \ - hw/extdev/ hw/arm/ imgread/ linux/ ./ deps/coreio/ deps/zlib/ deps/chdr/ deps/crypto/ \ - deps/libelf/ deps/chdpsr/ arm_emitter/ rend/ reios/ deps/libpng/ + hw/extdev/ hw/arm/ hw/naomi/ imgread/ linux/ ./ deps/coreio/ deps/zlib/ deps/chdr/ deps/crypto/ \ + deps/libelf/ deps/chdpsr/ arm_emitter/ rend/ reios/ deps/libpng/ ifdef WEBUI diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index 23278782a..2156cfeb5 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -570,8 +570,8 @@ struct maple_sega_vmu: maple_base lgLcdBitmap160x43x1 bmp; bmp.hdr.Format = LGLCD_BMP_FORMAT_160x43x1; - const BYTE white=0x00; - const BYTE black=0xFF; + const u8 white=0x00; + const u8 black=0xFF; //make it all black... memset(bmp.pixels,black,sizeof(bmp.pixels)); @@ -579,11 +579,11 @@ struct maple_sega_vmu: maple_base //decode from the VMU for(int y=0;y<32;++y) { - BYTE *dst=bmp.pixels+5816+((-y)*(48+112)); //ugly way to make things look right :p - BYTE *src=dev->lcd.data+6*y+5; + u8 *dst=bmp.pixels+5816+((-y)*(48+112)); //ugly way to make things look right :p + u8 *src=dev->lcd.data+6*y+5; for(int x=0;x<48/8;++x) { - BYTE val=*src; + u8 val=*src; for(int m=0;m<8;++m) { if(val&(1<<(m))) @@ -849,9 +849,9 @@ bool EEPROM_loaded = false; struct _NaomiState { - BYTE Cmd; - BYTE Mode; - BYTE Node; + u8 Cmd; + u8 Mode; + u8 Node; }; _NaomiState State; @@ -969,7 +969,7 @@ struct maple_naomi_jamma : maple_sega_controller case 0x10: { static char ID1[102] = "nullDC Team; I/O Plugin-1; ver0.2; for nullDC or other emus"; - buffer_out_b[0x8 + 0x10] = (BYTE)strlen(ID1) + 3; + buffer_out_b[0x8 + 0x10] = (u8)strlen(ID1) + 3; for (int i = 0; ID1[i] != 0; ++i) { buffer_out_b[0x8 + 0x13 + i] = ID1[i]; @@ -1037,9 +1037,10 @@ struct maple_naomi_jamma : maple_sega_controller static unsigned char LastKey[256]; static unsigned short coin1 = 0x0000; static unsigned short coin2 = 0x0000; - unsigned char Key[256]; + unsigned char Key[256] = { 0 }; +#if HOST_OS == OS_WINDOWS GetKeyboardState(Key); - +#endif if (keycode&NAOMI_SERVICE_KEY_1) //Service ? glbl |= 0x80; if (keycode&NAOMI_TEST_KEY_1) //Test diff --git a/core/hw/naomi/naomi.cpp b/core/hw/naomi/naomi.cpp index b0584aee7..5650ddb4a 100644 --- a/core/hw/naomi/naomi.cpp +++ b/core/hw/naomi/naomi.cpp @@ -12,18 +12,16 @@ #include "naomi_regs.h" u32 naomi_updates; -//For file memory mapping :p -#include //#define NAOMI_COMM u32 RomPioOffset=0; -DWORD DmaOffset; -DWORD DmaCount; +u32 DmaOffset; +u32 DmaCount; -DWORD BoardID=0x980055AA; -DWORD GSerialBuffer=0,BSerialBuffer=0; +u32 BoardID=0x980055AA; +u32 GSerialBuffer=0,BSerialBuffer=0; int GBufPos=0,BBufPos=0; int GState=0,BState=0; int GOldClk=0,BOldClk=0; @@ -84,7 +82,7 @@ void NaomiInit() DmaCount=0xffff; DmaOffset=0; - WORD CRC; + u16 CRC; CRC=CRCSerial(BSerial+2,0x2E); BSerial[0]=(u8)(CRC>>8); BSerial[1]=(u8)(CRC); @@ -150,7 +148,7 @@ u16 NaomiBoardIDRead() return (BSerialBuffer&(1<<(31-BBufPos)))?8:0; } -static DWORD AdaptByte(BYTE val) +static u32 AdaptByte(u8 val) { return val<<24; } @@ -283,7 +281,7 @@ void NaomiGameIDProcessCmd() } -void NaomiGameIDWrite(const WORD Data) +void NaomiGameIDWrite(const u16 Data) { int Dat=Data&0x01; int Clk=Data&0x02; @@ -344,7 +342,7 @@ void NaomiGameIDWrite(const WORD Data) } -WORD NaomiGameIDRead() +u16 NaomiGameIDRead() { return (GSerialBuffer&(1<<(31-GBufPos)))?1:0; } @@ -459,7 +457,7 @@ u32 ReadMem_naomi(u32 Addr, u32 sz) break; case NAOMI_DMA_COUNT_addr&255: - return (WORD) DmaCount; + return (u16) DmaCount; case NAOMI_BOARDID_READ_addr&255: return NaomiGameIDRead()?0x8000:0x0000; diff --git a/core/hw/naomi/naomi_cart.cpp b/core/hw/naomi/naomi_cart.cpp index d15b7cf6a..a4fb16c3b 100644 --- a/core/hw/naomi/naomi_cart.cpp +++ b/core/hw/naomi/naomi_cart.cpp @@ -4,13 +4,22 @@ u8* RomPtr; u32 RomSize; -HANDLE* RomCacheMap; +#if HOST_OS == OS_WINDOWS + typedef HANDLE fd_t; + #define INVALID_FD INVALID_HANDLE_VALUE +#else + typedef int fd_t; + #define INVALID_FD -1 + + #include + #include +#endif + +fd_t* RomCacheMap; u32 RomCacheMapCount; char SelectedFile[512]; -OPENFILENAME ofn; - bool naomi_cart_LoadRom(char* file) { @@ -80,14 +89,19 @@ bool naomi_cart_LoadRom(char* file) } RomCacheMapCount = (u32)files.size(); - RomCacheMap = new HANDLE[files.size()]; + RomCacheMap = new fd_t[files.size()]; strcpy(t, file); t[folder_pos] = 0; strcat(t, "ndcn-composed.cache"); //Allocate space for the ram, so we are sure we have a segment of continius ram +#if HOST_OS == OS_WINDOWS RomPtr = (u8*)VirtualAlloc(0, RomSize, MEM_RESERVE, PAGE_NOACCESS); +#else + RomPtr = (u8*)mmap(0, RomSize, PROT_NONE, MAP_PRIVATE, 0, 0); +#endif + verify(RomPtr != 0); strcpy(t, file); @@ -97,50 +111,71 @@ bool naomi_cart_LoadRom(char* file) { t[folder_pos] = 0; strcat(t, files[i].c_str()); - HANDLE RomCache; + fd_t RomCache; if (strcmp(files[i].c_str(), "null") == 0) { - RomCacheMap[i] = INVALID_HANDLE_VALUE; + RomCacheMap[i] = INVALID_FD; continue; } - +#if HOST_OS == OS_WINDOWS RomCache = CreateFile(t, FILE_READ_ACCESS, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - - if (RomCache == INVALID_HANDLE_VALUE) +#else + RomCache = open(t, O_RDONLY); +#endif + if (RomCache == INVALID_FD) { wprintf(L"-Unable to read file %s\n", files[i].c_str()); - RomCacheMap[i] = INVALID_HANDLE_VALUE; + RomCacheMap[i] = INVALID_FD; continue; } - +#if HOST_OS == OS_WINDOWS RomCacheMap[i] = CreateFileMapping(RomCache, 0, PAGE_READONLY, 0, fsize[i], 0); - verify(RomCacheMap[i] != INVALID_HANDLE_VALUE); - wprintf(L"-Preparing \"%s\" at 0x%08X, size 0x%08X\n", files[i].c_str(), fstart[i], fsize[i]); - verify(CloseHandle(RomCache)); +#else + RomCacheMap[i] = RomCache; +#endif + + verify(RomCacheMap[i] != INVALID_FD); + wprintf(L"-Preparing \"%s\" at 0x%08X, size 0x%08X\n", files[i].c_str(), fstart[i], fsize[i]); } //We have all file mapping objects, we start to map the ram printf("+Mapping ROM\n"); //Release the segment we reserved so we can map the files there +#if HOST_OS == OS_WINDOWS verify(VirtualFree(RomPtr, 0, MEM_RELEASE)); +#else + munmap(RomPtr, RomSize); +#endif //Map the files into the segment of the ram that was reserved for (size_t i = 0; i