Update of /cvsroot/arcem/arcem/arch In directory vz-cvs-4.sog:/tmp/cvs-serv17595/arch
Modified Files: archio.c armarc.c armarc.h displaydev.c extnrom.c fastmap.c filecommon.c i2c.c keyboard.c newsound.c stddisplaydev.c Log Message: Enormous-looking set of changes that do nothing. Just avoid requiring a C99 compiler. Would you believe Microsoft Visual Studio 2010 is still not a C99 compiler. So we fake it where we can, but the main problem is that you require C99 to be able to do inline declarations. So the bulk of this huge ugly commit is just changing the scope of declaration of variables. I've done as much as I can to test I've not broken things, on Linux and Windows VS2010 builds. It's possible there's breakage with other platforms but those are the two I've got to hand to test just now anyway. Index: newsound.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/newsound.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- newsound.c 12 May 2012 17:34:51 -0000 1.3 +++ newsound.c 21 Jul 2012 01:01:11 -0000 1.4 @@ -476,17 +476,19 @@ static void Sound_DMAEvent(ARMul_State *state,CycleCount nowtime) { + int32_t srcbatchsize, avail; + CycleCount next; Sound_UpdateDMARate(state); #ifdef SOUND_SUPPORT /* Work out how many source samples are required to generate Sound_BatchSize dest samples */ - int32_t srcbatchsize = (Sound_BatchSize*soundTimeStep)>>TIMESHIFT; + srcbatchsize = (Sound_BatchSize*soundTimeStep)>>TIMESHIFT; if(!srcbatchsize) srcbatchsize = 1; #else - int srcbatchsize = 4; + srcbatchsize = 4; #endif /* How many DMA fetches are possible? */ - int32_t avail = 0; + avail = 0; if(MEMC.ControlReg & (1 << 11)) { /* Trigger any pending buffer swap */ @@ -528,7 +530,7 @@ #endif /* Work out when to reschedule the event TODO - This is wrong; there's no guarantee the host accepted all the data we wanted to give him */ - CycleCount next = Sound_DMARate*(avail?avail:srcbatchsize)+Sound_FudgeRate; + next = Sound_DMARate*(avail?avail:srcbatchsize)+Sound_FudgeRate; /* Clamp to a safe minimum value */ if(next < 100) next = 100; Index: armarc.h =================================================================== RCS file: /cvsroot/arcem/arcem/arch/armarc.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- armarc.h 12 May 2012 17:34:51 -0000 1.13 +++ armarc.h 21 Jul 2012 01:01:11 -0000 1.14 @@ -147,7 +147,10 @@ /* ------------------- inlined higher-level memory funcs ---------------------- */ +#ifndef _MSC_VER #define FASTMAP_INLINE +#endif + #ifdef FASTMAP_INLINE #define FASTMAP_PROTO static #else Index: keyboard.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/keyboard.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- keyboard.c 12 May 2012 17:34:51 -0000 1.11 +++ keyboard.c 21 Jul 2012 01:01:11 -0000 1.12 @@ -320,11 +320,12 @@ void Keyboard_Poll(ARMul_State *state,CycleCount nowtime) { + int KbdSerialVal; EventQ_RescheduleHead(state,nowtime+12500,Keyboard_Poll); /* TODO - Should probably be realtime */ /* Call host-specific routine */ Kbd_PollHostKbd(state); /* Keyboard check */ - int KbdSerialVal = IOC_ReadKbdTx(state); + KbdSerialVal = IOC_ReadKbdTx(state); if (KbdSerialVal != -1) { Kbd_CodeFromHost(state, (uint8_t) KbdSerialVal); } else { Index: extnrom.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/extnrom.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- extnrom.c 12 May 2012 17:34:51 -0000 1.10 +++ extnrom.c 21 Jul 2012 01:01:11 -0000 1.11 @@ -49,7 +49,7 @@ assert(address != NULL); - addr[0] = data; + addr[0] = data & 255; addr[1] = data >> 8; } Index: i2c.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/i2c.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- i2c.c 12 May 2012 17:34:51 -0000 1.14 +++ i2c.c 21 Jul 2012 01:01:11 -0000 1.15 @@ -3,7 +3,6 @@ #include <signal.h> #include <stdio.h> #include <time.h> -#include <inttypes.h> #include "../armdefs.h" #ifdef MACOSX @@ -177,12 +176,8 @@ OutFile = fopen("hexcmos","w"); } #else -#ifdef SYSTEM_gp2x - OutFile = fopen("/mnt/sd/arcem/hexcmos","w"); -#else OutFile = fopen("hexcmos","w"); #endif -#endif if (OutFile == NULL) { fprintf(stderr,"SaveCMOS: Could not open (hexcmos.updated) CMOS settings file\n"); exit(1); @@ -268,12 +263,12 @@ bit we are going to ignore it; the last bit tells us rNw */ I2C.LastrNw=I2C.DataBuffer & 1; dbug_i2c("I2C simulator got slave address " - "%#" PRIxFAST16 "\n", I2C.DataBuffer); + "%d\n", (int) I2C.DataBuffer); if ((I2C.DataBuffer & 0xfe)!=0xa0) { /* Hey - its a request for a different I2C peripheral - like an A500's timer chip */ fprintf(stderr, "I2C simulator got wierd slave address " - "%#" PRIxFAST16 "\n", I2C.DataBuffer); + "%d\n", (int) I2C.DataBuffer); I2C.IAmTransmitter=false; I2C.NumberOfBitsSoFar=0; I2C.state=I2CChipState_Idle; @@ -440,8 +435,6 @@ #elif defined(MACOSX) chdir(arcemDir); path = "hexcmos"; -#elif defined(SYSTEM_gp2x) - path = "/mnt/sd/arcem/hexcmos"; #else path = "hexcmos"; #endif Index: displaydev.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/displaydev.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- displaydev.c 12 May 2012 17:34:51 -0000 1.3 +++ displaydev.c 21 Jul 2012 01:01:11 -0000 1.4 @@ -217,12 +217,12 @@ ARMword tempsrc2 = *src++; if(destalign) { - ARMword tempdest = EndianSwap(*dest); + ARMword tempsrc3, tempdest = EndianSwap(*dest); ARMword mask = (count<=invdestalign?(1<<count):0)-1; mask = mask<<destalign; tempdest &= ~mask; - ARMword tempsrc3 = (tempsrc1>>srcalign); + tempsrc3 = (tempsrc1>>srcalign); if(srcalign) tempsrc3 |= (tempsrc2<<invsrcalign); tempdest |= (tempsrc1<<destalign) & mask; @@ -295,8 +295,7 @@ unsigned int pixels = 1; while((destbpp*pixels < 32) && (srcbpp*pixels < 8)) pixels <<= 1; /* Should only need to consider powers of two */ - unsigned int srcbits = 1<<(srcbpp*pixels); - return srcbits; + return 1<<(srcbpp*pixels); } /* @@ -312,12 +311,12 @@ void GenExpandTable(ARMword *dest,unsigned int srcbpp,unsigned int factor,ARMword mul) { - unsigned int destbpp = srcbpp<<factor; + ARMword i,j; + unsigned int srcbits, destbpp = srcbpp<<factor; unsigned int pixels = 1; while((destbpp*pixels < 32) && (srcbpp*pixels < 8)) pixels <<= 1; - unsigned int srcbits = 1<<(srcbpp*pixels); - ARMword i,j; + srcbits = 1<<(srcbpp*pixels); for(i=0;i<srcbits;i++) { ARMword out = 0; @@ -346,25 +345,28 @@ void BitCopyExpand(ARMword *dest,int destalign,const ARMword *src,int srcalign,int count,const ARMword *expandtable,unsigned int srcbpp,unsigned int factor) { + int invdestalign, invsrcalign; + ARMword srcmask, tempsrc1, tempsrc2; + unsigned int srcbits, destbits; unsigned int destbpp = srcbpp<<factor; unsigned int pixels = 1; while((destbpp*pixels < 32) && (srcbpp*pixels < 8)) pixels <<= 1; - unsigned int srcbits = srcbpp*pixels; - unsigned int destbits = destbpp*pixels; - ARMword srcmask = (1<<srcbits)-1; + srcbits = srcbpp*pixels; + destbits = destbpp*pixels; + srcmask = (1<<srcbits)-1; /* Get the destination word aligned */ - int invdestalign = 32-destalign; - int invsrcalign = 32-srcalign; - ARMword tempsrc1 = *src++; - ARMword tempsrc2 = *src++; + invdestalign = 32-destalign; + invsrcalign = 32-srcalign; + tempsrc1 = *src++; + tempsrc2 = *src++; if(destalign) { - ARMword tempdest = EndianSwap(*dest); + ARMword tempsrc3, tempdest = EndianSwap(*dest); ARMword destmask = (count<=invdestalign?(1<<count):0)-1; destmask = destmask<<destalign; tempdest &= ~destmask; - ARMword tempsrc3 = (tempsrc1>>srcalign); + tempsrc3 = (tempsrc1>>srcalign); if(srcalign) tempsrc3 |= (tempsrc2<<invsrcalign); while(destalign < 32) @@ -389,13 +391,13 @@ { /* Table isn't big enough for us to get one full word per entry */ ARMword tempsrc3 = (tempsrc1>>srcalign); - if(srcalign) - tempsrc3 |= (tempsrc2<<invsrcalign); int remaining = 32; ARMword tempdest = 0; int outshift = 0; /* There will be (count<<factor)>>5 full words available, and we want to stop when there's less than one full word left */ int bitsleft = (count<<factor)&0x1f; + if(srcalign) + tempsrc3 |= (tempsrc2<<invsrcalign); while(count > bitsleft) { tempdest |= expandtable[tempsrc3 & srcmask]<<outshift; @@ -428,12 +430,12 @@ } else { + int remaining = 32; /* One output word for every srcbits */ ARMword tempsrc3 = (tempsrc1>>srcalign); if(srcalign) tempsrc3 |= (tempsrc2<<invsrcalign); - int remaining = 32; - while(count >= srcbits) + while(count >= (int)srcbits) { *dest++ = EndianSwap(expandtable[tempsrc3 & srcmask]); tempsrc3 >>= srcbits; @@ -461,11 +463,11 @@ /* End bits */ ARMword tempdest = EndianSwap(*dest); ARMword destmask = 0xffffffff<<(count<<factor); - tempdest &= destmask; ARMword tempsrc3 = (tempsrc1>>srcalign); + int outshift = 0; + tempdest &= destmask; if(srcalign) tempsrc3 |= (tempsrc2<<invsrcalign); - int outshift = 0; while(count) { ARMword in = expandtable[tempsrc3 & ((1<<srcbpp)-1)]; /* One pixel at a time for simplicity */ Index: fastmap.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/fastmap.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- fastmap.c 12 May 2012 17:34:51 -0000 1.3 +++ fastmap.c 21 Jul 2012 01:01:11 -0000 1.4 @@ -1,7 +1,7 @@ #ifndef FASTMAP_INLINE #define FASTMAP_FUNC #else -#define FASTMAP_FUNC static inline +#define FASTMAP_FUNC static #endif /** @@ -15,11 +15,14 @@ */ FASTMAP_FUNC ARMword ARMul_LoadWordS(ARMul_State *state,ARMword address) { + FastMapEntry *entry; + FastMapRes res; + state->NumCycles++; address &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,address); - FastMapRes res = FastMap_DecodeRead(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,address); + res = FastMap_DecodeRead(entry,state->FastMapMode); ARMul_CLEARABORT; /* More likely to clear the abort than not */ if(FASTMAP_RESULT_DIRECT(res)) { @@ -47,11 +50,14 @@ */ FASTMAP_FUNC ARMword ARMul_LoadByte(ARMul_State *state,ARMword address) { + FastMapEntry *entry; + FastMapRes res; + state->NumCycles++; address &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,address); - FastMapRes res = FastMap_DecodeRead(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,address); + res = FastMap_DecodeRead(entry,state->FastMapMode); ARMul_CLEARABORT; /* More likely to clear the abort than not */ if(FASTMAP_RESULT_DIRECT(res)) { @@ -82,11 +88,14 @@ */ FASTMAP_FUNC void ARMul_StoreWordS(ARMul_State *state, ARMword address, ARMword data) { + FastMapEntry *entry; + FastMapRes res; + state->NumCycles++; address &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,address); - FastMapRes res = FastMap_DecodeWrite(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,address); + res = FastMap_DecodeWrite(entry,state->FastMapMode); // fprintf(stderr,"StoreWordS: %08x maps to entry %08x res %08x (mode %08x pc %08x)\n",address,entry,res,MEMC.FastMapMode,state->Reg[15]); ARMul_CLEARABORT; if(FASTMAP_RESULT_DIRECT(res)) @@ -116,11 +125,14 @@ */ FASTMAP_FUNC void ARMul_StoreByte(ARMul_State *state, ARMword address, ARMword data) { + FastMapEntry *entry; + FastMapRes res; + state->NumCycles++; address &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,address); - FastMapRes res = FastMap_DecodeWrite(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,address); + res = FastMap_DecodeWrite(entry,state->FastMapMode); ARMul_CLEARABORT; if(FASTMAP_RESULT_DIRECT(res)) { @@ -153,13 +165,15 @@ */ FASTMAP_FUNC ARMword ARMul_SwapWord(ARMul_State *state, ARMword address, ARMword data) { + FastMapEntry *entry; + FastMapRes res; ARMword temp; state->NumCycles+=2; address &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,address); - FastMapRes res = FastMap_DecodeWrite(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,address); + res = FastMap_DecodeWrite(entry,state->FastMapMode); ARMul_CLEARABORT; if(FASTMAP_RESULT_DIRECT(res)) { @@ -180,6 +194,7 @@ { state->NumCycles--; ARMul_DATAABORT(address); + return -1; } } @@ -195,13 +210,15 @@ */ FASTMAP_FUNC ARMword ARMul_SwapByte(ARMul_State *state, ARMword address, ARMword data) { + FastMapEntry *entry; + FastMapRes res; ARMword temp; state->NumCycles+=2; address &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,address); - FastMapRes res = FastMap_DecodeWrite(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,address); + res = FastMap_DecodeWrite(entry,state->FastMapMode); ARMul_CLEARABORT; if(FASTMAP_RESULT_DIRECT(res)) { @@ -225,5 +242,6 @@ { state->NumCycles--; ARMul_DATAABORT(address); + return -1; } } Index: filecommon.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/filecommon.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- filecommon.c 12 May 2012 17:34:51 -0000 1.3 +++ filecommon.c 21 Jul 2012 01:01:11 -0000 1.4 @@ -12,7 +12,6 @@ #include <stdio.h> #include <stddef.h> -#include <stdbool.h> #include "armarc.h" #include "filecalls.h" @@ -54,8 +53,8 @@ static void filebuffer_fill(void) { - filebuffer_offset = 0; size_t temp = MIN(filebuffer_remain,MAX_FILEBUFFER); + filebuffer_offset = 0; filebuffer_buffered = fread(buffer,1,temp,filebuffer_file); if(filebuffer_buffered != temp) filebuffer_remain = 0; @@ -65,12 +64,13 @@ static void filebuffer_initread(FILE *pFile,size_t uCount) { + size_t temp; filebuffer_inuse = false; filebuffer_file = pFile; if(uCount <= MIN_FILEBUFFER) return; filebuffer_inuse = true; - size_t temp = MIN(uCount,MAX_FILEBUFFER); + temp = MIN(uCount,MAX_FILEBUFFER); ensure_buffer_size(temp); filebuffer_remain = uCount; filebuffer_fill(); @@ -78,6 +78,7 @@ static size_t filebuffer_read(uint8_t *pBuffer,size_t uCount,bool endian) { + size_t ret, avail; if(!filebuffer_inuse) { if(endian) @@ -85,7 +86,7 @@ else return fread(pBuffer,1,uCount,filebuffer_file); } - size_t ret = 0; + ret = 0; while(uCount) { if(filebuffer_buffered == filebuffer_offset) @@ -94,7 +95,7 @@ return ret; filebuffer_fill(); } - size_t avail = MIN(uCount,filebuffer_buffered-filebuffer_offset); + avail = MIN(uCount,filebuffer_buffered-filebuffer_offset); if(endian) InvByteCopy(pBuffer,buffer+filebuffer_offset,avail); else @@ -109,6 +110,7 @@ static void filebuffer_initwrite(FILE *pFile,size_t uCount) { + size_t temp; filebuffer_inuse = false; filebuffer_file = pFile; filebuffer_remain = uCount; /* Actually treated as total writeable */ @@ -116,7 +118,7 @@ if(uCount <= MIN_FILEBUFFER) return; filebuffer_inuse = true; - size_t temp = MIN(uCount,MAX_FILEBUFFER); + temp = MIN(uCount,MAX_FILEBUFFER); ensure_buffer_size(temp); filebuffer_offset = 0; } @@ -127,8 +129,8 @@ return; if(!filebuffer_inuse) { - uCount = MIN(uCount,filebuffer_remain-filebuffer_buffered); size_t temp; + uCount = MIN(uCount,filebuffer_remain-filebuffer_buffered); if(endian) temp = File_WriteEmu(filebuffer_file,pBuffer,uCount); else @@ -269,26 +271,31 @@ while(uCount > 0) { + FastMapEntry *entry; + FastMapRes res; size_t amt = MIN(4096-(uAddress&4095),uCount); uAddress &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,uAddress); - FastMapRes res = FastMap_DecodeWrite(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,uAddress); + res = FastMap_DecodeWrite(entry,state->FastMapMode); if(FASTMAP_RESULT_DIRECT(res)) { + size_t temp, temp2; + ARMEmuFunc *func; uint8_t *phy = (uint8_t *) FastMap_Log2Phy(entry,uAddress); /* Scan ahead to work out the size of this memory block */ while(amt < uCount) { + uint8_t *phy2; ARMword uAddrNext = (uAddress+amt) & UINT32_C(0x3ffffff); size_t amt2 = MIN(4096,uCount-amt); FastMapEntry *entry2 = FastMap_GetEntryNoWrap(state,uAddrNext); FastMapRes res2 = FastMap_DecodeRead(entry2,state->FastMapMode); if(!FASTMAP_RESULT_DIRECT(res2)) break; - uint8_t *phy2 = (uint8_t *) FastMap_Log2Phy(entry2,uAddrNext); + phy2 = (uint8_t *) FastMap_Log2Phy(entry2,uAddrNext); if(phy2 != phy+amt) break; /* These fastmap pages are contiguous in physical memory */ @@ -296,14 +303,14 @@ } #ifdef USE_FILEBUFFER - size_t temp = filebuffer_read(phy,amt,true); + temp = filebuffer_read(phy,amt,true); #else - size_t temp = File_ReadEmu(pFile,phy,amt); + temp = File_ReadEmu(pFile,phy,amt); #endif /* Clobber emu funcs for that region */ - size_t temp2 = (temp+(uAddress&3)+3)&~UINT32_C(3); - ARMEmuFunc *func = FastMap_Phy2Func(state,(ARMword *) (phy-(uAddress&3))); + temp2 = (temp+(uAddress&3)+3)&~UINT32_C(3); + func = FastMap_Phy2Func(state,(ARMword *) (phy-(uAddress&3))); while(temp2>0) { *func++ = FASTMAP_CLOBBEREDFUNC; @@ -319,6 +326,7 @@ } else if(FASTMAP_RESULT_FUNC(res)) { + ARMword *w; /* Read into temp buffer */ #ifdef USE_FILEBUFFER size_t temp = filebuffer_read(temp_buf+(uAddress&3),amt,false); @@ -336,7 +344,7 @@ c++; } /* Deal with main body */ - ARMword *w = (ARMword *) c; + w = (ARMword *) c; while(temp2 >= 4) { FastMap_StoreFunc(entry,state,uAddress,EndianSwap(*w),0); @@ -393,12 +401,14 @@ while(uCount > 0) { + FastMapEntry *entry; + FastMapRes res; size_t amt = MIN(4096-(uAddress&4095),uCount); uAddress &= UINT32_C(0x3ffffff); - FastMapEntry *entry = FastMap_GetEntryNoWrap(state,uAddress); - FastMapRes res = FastMap_DecodeRead(entry,state->FastMapMode); + entry = FastMap_GetEntryNoWrap(state,uAddress); + res = FastMap_DecodeRead(entry,state->FastMapMode); if(FASTMAP_RESULT_DIRECT(res)) { uint8_t *phy = (uint8_t *) FastMap_Log2Phy(entry,uAddress); @@ -406,13 +416,14 @@ /* Scan ahead to work out the size of this memory block */ while(amt < uCount) { + uint8_t *phy2; ARMword uAddrNext = (uAddress+amt) & 0x3ffffff; size_t amt2 = MIN(4096,uCount-amt); FastMapEntry *entry2 = FastMap_GetEntryNoWrap(state,uAddrNext); FastMapRes res2 = FastMap_DecodeRead(entry2,state->FastMapMode); if(!FASTMAP_RESULT_DIRECT(res2)) break; - uint8_t *phy2 = (uint8_t *) FastMap_Log2Phy(entry2,uAddrNext); + phy2 = (uint8_t *) FastMap_Log2Phy(entry2,uAddrNext); if(phy2 != phy+amt) break; /* These fastmap pages are contiguous in physical memory */ @@ -425,6 +436,7 @@ uAddress += amt; uCount -= amt; #else + { size_t temp = File_WriteEmu(pFile,phy,amt); /* Update state */ @@ -433,6 +445,7 @@ break; uAddress += temp; uCount -= temp; + } #endif } else if(FASTMAP_RESULT_FUNC(res)) Index: armarc.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/armarc.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- armarc.c 12 May 2012 17:34:51 -0000 1.39 +++ armarc.c 21 Jul 2012 01:01:11 -0000 1.40 @@ -58,7 +58,8 @@ static void DumpHandler(int sig) { ARMul_State *state = &statestr; FILE *res; - int i; + int i, idx; + ARMword size; fprintf(stderr,"SIGUSR2 at PC=0x%x\n",ARMul_GetPC(state)); #ifndef WIN32 @@ -116,8 +117,7 @@ /* Memory map */ fprintf(stderr,"MEMC using %dKB page size\n",4<<MEMC.PageSizeFlags); - ARMword size=1<<(12+MEMC.PageSizeFlags); - int idx; + size=1<<(12+MEMC.PageSizeFlags); for(idx=0;idx<512;idx++) { int32_t pt = MEMC.PageTable[idx]; @@ -190,6 +190,7 @@ unsigned ARMul_MemoryInit(ARMul_State *state) { + ARMword RAMChunkSize; FILE *ROMFile; int PresPage; unsigned int i; @@ -274,11 +275,7 @@ arcem_exit("Couldn't open ROM file"); } #else -#ifdef SYSTEM_gp2x - if (ROMFile = fopen("/mnt/sd/arcem/rom", "rb"), ROMFile == NULL) { -#else if (ROMFile = fopen(hArcemConfig.sRomImageName, "rb"), ROMFile == NULL) { -#endif fprintf(stderr, "Couldn't open ROM file\n"); exit(2); } @@ -307,7 +304,7 @@ (MEMC.ROMHighSize + extnrom_size) / 1024); /* Now allocate ROMs & RAM in one chunk */ - ARMword RAMChunkSize = MAX(MEMC.RAMSize,512*1024); /* Ensure at least 512K RAM allocated to avoid any issues caused by DMA pointers going out of range */ + RAMChunkSize = MAX(MEMC.RAMSize,512*1024); /* Ensure at least 512K RAM allocated to avoid any issues caused by DMA pointers going out of range */ MEMC.ROMRAMChunk = calloc(RAMChunkSize+MEMC.ROMHighSize+extnrom_size+256,1); MEMC.EmuFuncChunk = calloc(RAMChunkSize+MEMC.ROMHighSize+extnrom_size+256,sizeof(FastMapUInt)/4); if((MEMC.ROMRAMChunk == NULL) || (MEMC.EmuFuncChunk == NULL)) { @@ -415,9 +412,11 @@ the mangling. This corresponds to row bits 0-7 and column bits 0-1, 4-8. So all we need to do is calculate row bits 8,9 and column bits 2,3,9. */ + ARMword bank; if(MEMC.PageSizeFlags != MEMC.DRAMPageSize) { + ARMword b12=0,b13=0,b19=0,b20=0,b21=0; ARMword r8=0,r9=0,c2=0,c3=0,c9=0; switch(MEMC.PageSizeFlags) @@ -450,8 +449,6 @@ /* Now translate back */ - ARMword b12=0,b13=0,b19=0,b20=0,b21=0; - switch(MEMC.DRAMPageSize) { case MEMC_PAGESIZE_O_4K: @@ -487,7 +484,7 @@ will wrap back to bank 0. */ - ARMword bank = phy>>22; + bank = phy>>22; phy &= MEMC.RAMMask; @@ -527,10 +524,14 @@ static void ARMul_PurgeFastMapPTIdx(ARMword idx) { + FastMapEntry *entry; + FastMapUInt addr; + ARMword size; + int32_t pt; if(MEMC.ROMMapFlag) return; /* Still in ROM mode, abort */ - int32_t pt = MEMC.PageTable[idx]; + pt = MEMC.PageTable[idx]; if(pt>0) { ARMword logadr,phys,mask; @@ -561,17 +562,17 @@ mask = 0x7f8c00; break; } - ARMword size=12+MEMC.PageSizeFlags; + size=12+MEMC.PageSizeFlags; phys = ARMul_ManglePhysAddr(phys<<size); size = 1<<size; - FastMapEntry *entry = FastMap_GetEntryNoWrap(&statestr,logadr); + entry = FastMap_GetEntryNoWrap(&statestr,logadr); /* To cope with multiply mapped pages (i.e. multiple physical pages mapping to the same logical page) we need to check if the page we're about to unmap is still owned by us If it is owned by us, we'll have to search the page tables for a replacement (if any) Otherwise we don't need to do anything at all Note that we only need to check the first page for ownership, because any change to the page size will result in the full map being rebuilt */ - FastMapUInt addr = ((FastMapUInt)(MEMC.PhysRam+(phys>>2)))-logadr; /* Address part of FlagsAndData */ + addr = ((FastMapUInt)(MEMC.PhysRam+(phys>>2)))-logadr; /* Address part of FlagsAndData */ if((entry->FlagsAndData<<8) == addr) { /* We own this page */ @@ -630,8 +631,9 @@ static void ARMul_RebuildFastMapPTIdx(ARMword idx) { - if(MEMC.ROMMapFlag) - return; /* Still in ROM mode, abort */ + int32_t pt; + ARMword size; + FastMapUInt flags; static const FastMapUInt PPL_To_Flags[4] = { FASTMAP_R_USR|FASTMAP_R_OS|FASTMAP_R_SVC|FASTMAP_W_USR|FASTMAP_W_OS|FASTMAP_W_SVC, /* PPL 00 */ @@ -640,7 +642,10 @@ FASTMAP_R_OS|FASTMAP_R_SVC|FASTMAP_W_SVC, /* PPL 11 */ }; - int32_t pt = MEMC.PageTable[idx]; + if(MEMC.ROMMapFlag) + return; /* Still in ROM mode, abort */ + + pt = MEMC.PageTable[idx]; if(pt>0) { ARMword logadr,phys; @@ -667,10 +672,10 @@ | ((pt & 0x000c00)<<13); break; } - ARMword size=12+MEMC.PageSizeFlags; + size=12+MEMC.PageSizeFlags; phys = ARMul_ManglePhysAddr(phys<<size); size = 1<<size; - FastMapUInt flags = PPL_To_Flags[(pt>>8)&3]; + flags = PPL_To_Flags[(pt>>8)&3]; if((phys<512*1024) && DisplayDev_UseUpdateFlags) { /* DMAable, must use func on write */ @@ -795,13 +800,14 @@ static ARMword FastMap_PhysRamFuncROMMap2(ARMul_State *state, ARMword addr,ARMword data,ARMword flags) { + ARMword *phy; /* Read/write from phys RAM, switching to ROMMapFlag 0 if necessary */ if(MEMC.ROMMapFlag == 2) { MEMC.ROMMapFlag = 0; ARMul_RebuildFastMap(); } - ARMword *phy = FastMap_Log2Phy(FastMap_GetEntry(state,addr),addr&~3); + phy = FastMap_Log2Phy(FastMap_GetEntry(state,addr),addr&~3); if(!(flags & FASTMAP_ACCESSFUNC_WRITE)) return *phy; if(flags & FASTMAP_ACCESSFUNC_BYTE) @@ -820,10 +826,11 @@ static ARMword FastMap_PhysRamFunc(ARMul_State *state, ARMword addr,ARMword data,ARMword flags) { + ARMword *phy, orig; /* Write to direct-mapped phys RAM. Address guaranteed to be valid. */ addr -= MEMORY_0x2000000_RAM_PHYS; - ARMword *phy = &MEMC.PhysRam[addr>>2]; - ARMword orig = *phy; + phy = &MEMC.PhysRam[addr>>2]; + orig = *phy; if(flags & FASTMAP_ACCESSFUNC_BYTE) { ARMword shift = ((addr&3)<<3); @@ -933,6 +940,7 @@ void ARMul_RebuildFastMap(void) { ARMword i; + FastMapEntry *entry; /* completely rebuild the fast map */ switch(MEMC.ROMMapFlag) @@ -1003,7 +1011,7 @@ FastMap_SetEntries(MEMORY_0x3400000_R_ROM_LOW,0,FastMap_DMAFunc,FASTMAP_R_USR|FASTMAP_R_SVC|FASTMAP_R_OS|FASTMAP_W_SVC|FASTMAP_W_FUNC|FASTMAP_R_FUNC,0x400000); /* Overwrite with VIDC */ - FastMapEntry *entry = FastMap_GetEntryNoWrap(&statestr,MEMORY_0x3400000_W_VIDEOCON); + entry = FastMap_GetEntryNoWrap(&statestr,MEMORY_0x3400000_W_VIDEOCON); for(i=0;i<MEMORY_0x3600000_W_DMA_GEN-MEMORY_0x3400000_W_VIDEOCON;i+=4096) { entry->AccessFunc = FastMap_VIDCFunc; Index: stddisplaydev.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/stddisplaydev.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- stddisplaydev.c 12 May 2012 17:34:51 -0000 1.3 +++ stddisplaydev.c 21 Jul 2012 01:01:11 -0000 1.4 @@ -349,16 +349,20 @@ static int SDD_Name(RowFunc1bpp1X)(ARMul_State *state,int row,SDD_Row drow,int flags) { - int i; + int i, Remaining, startRemain; + uint32_t Vptr, Vstart, Vend, startVptr; + const ARMword *RAM; + const uint32_t *MEMC_UpdateFlags; + uint32_t *HD_UpdateFlags; SDD_HostColour *Palette = HD.Palette; /* Handle palette updates */ [...1220 lines suppressed...] - row = VIDC.Vert_BorderStart+1; /* Skip pre-border rows */ + int nextrow; int stop = DC.NextRow; bool dmaen = DC.DMAEn; bool flybk = false; + int row = DC.LastRow; + if(row < VIDC.Vert_BorderStart+1) + row = VIDC.Vert_BorderStart+1; /* Skip pre-border rows */ while(row < stop) { if(row < (VIDC.Vert_DisplayStart+1)) @@ -2072,7 +2169,7 @@ flybk = true; } /* Skip ahead to next row */ - int nextrow = row+SDD_RowsAtOnce; + nextrow = row+SDD_RowsAtOnce; if((SDD_RowsAtOnce > 1) && (row <= VIDC.Vert_Cycle) && (nextrow > VIDC.Vert_Cycle+1)) nextrow = VIDC.Vert_Cycle+1; SDD_Name(Reschedule)(state,nowtime,SDD_Name(RowStart),nextrow,flybk); Index: archio.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/archio.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- archio.c 12 May 2012 17:34:51 -0000 1.11 +++ archio.c 21 Jul 2012 01:01:11 -0000 1.12 @@ -31,14 +31,12 @@ /*-----------------------------------------------------------------------------*/ -#ifndef SYSTEM_gp2x static void FDCHDC_Poll(ARMul_State *state,CycleCount nowtime) { EventQ_RescheduleHead(state,nowtime+250,FDCHDC_Poll); /* TODO - This probably needs to be made realtime */ FDC_Regular(state); HDC_Regular(state); } -#endif /*-----------------------------------------------------------------------------*/ void @@ -72,9 +70,7 @@ FDC_Init(state); HDC_Init(state); Kbd_Init(state); -#ifndef SYSTEM_gp2x EventQ_Insert(state,ARMul_Time+250,FDCHDC_Poll); -#endif } /* IO_Init */ /*------------------------------------------------------------------------------*/ @@ -155,12 +151,13 @@ /*------------------------------------------------------------------------------*/ static void UpdateTimerRegisters_Internal(ARMul_State *state,CycleCount nowtime,int idx) { + uint32_t tmpL; + CycleDiff scaledTimeSlip, nextTrigger; CycleDiff timeSinceLastUpdate = nowtime - ioc.TimersLastUpdated; /* Take into account any lost fractions of an IOC tick */ uint64_t TimeSlip = (((uint64_t) timeSinceLastUpdate) * ioc.IOCRate)+ioc.TimerFracBit; ioc.TimerFracBit = TimeSlip & 0xffff; - CycleDiff scaledTimeSlip = TimeSlip>>16; - uint32_t tmpL; + scaledTimeSlip = (CycleDiff) (TimeSlip>>16); /* In theory we should be able to use MAX_CYCLES_INTO_FUTURE as our default next trigger time. But some software (e.g. Lotus Turbo Challenge II) seems @@ -168,7 +165,7 @@ happens (presumably due a bug in ArcEm somewhere). So use a failsafe default next trigger time of 65536 IOC cycles from now (i.e. the max possible timer period) */ - CycleDiff nextTrigger = ioc.InvIOCRate; /* a.k.a. 65536 IOC cycles from now */ + nextTrigger = ioc.InvIOCRate; /* a.k.a. 65536 IOC cycles from now */ /* ----------------------------------------------------------------- */ tmpL = ioc.TimerInputLatch[0]+1; @@ -183,7 +180,7 @@ if (ioc.Timer0CanInt) { tmpL = (((uint64_t) (ioc.TimerCount[0]+1)) * ioc.InvIOCRate) >> 16; - if (tmpL < nextTrigger) nextTrigger = tmpL; + if ((int)tmpL < nextTrigger) nextTrigger = tmpL; } /* ----------------------------------------------------------------- */ @@ -198,7 +195,7 @@ if (ioc.Timer1CanInt) { tmpL = (((uint64_t) (ioc.TimerCount[1]+1)) * ioc.InvIOCRate) >> 16; - if (tmpL < nextTrigger) nextTrigger = tmpL; + if ((int)tmpL < nextTrigger) nextTrigger = tmpL; } /* ----------------------------------------------------------------- */ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ -- arcem-cvs mailing list arcem-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/arcem-cvs