From 3a4a57fa5a558064188bec9442847f6da0b184fc Mon Sep 17 00:00:00 2001 From: mudlord Date: Thu, 1 Nov 2007 06:05:39 +0000 Subject: [PATCH] Fixed bug in GB/GBC mode as described and detailed by Dwedit. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@10 a31d4220-a93d-0410-bf67-fe4944624d44 --- VBA.suo | Bin 53248 -> 53248 bytes src/gb/GB.cpp | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/VBA.suo b/VBA.suo index 6b6d8a4c5abbdbcf0a9673a8e7d8e25fb40c0e0f..f8fa64e903c1fb2fa0eb52865c37511c5f8642db 100644 GIT binary patch delta 1796 zcmb_cYe<`C6n@_?-{-9{i)$QS(wfG4L1VmPof{f!J7cO;cd4CAi$+b1iAiQ+#2_)#bOI*@JcItIHHtT4vdezY>Au)@sF7tO@dY%T1-;k@Va zzURE>7M)i`=T!?{Q4{z&S2&_y<|;-oDM!Tng6QUqA(UDrZp30STuMEzt-pNsi!A?4 z+u6@s7JtdTUXQtjD%p~DMxVkC(LEbJP2Y{a^c<}3f0>sjI5|`_%WG|9aF{hRJ8NZr zHptw}$6Um{MBF$VV*_l68MbsoBoDAL`9R4oRf)hj1+q%le>z7lo&TK7q#01+jN6d|0?m&9Y|3;yWOmj@?<8O(k&~v!P0FK# z!Z%JcnxD&t)>De5b^|VkKE$x^85o>e+-Wdkd2t0Z-ZB_u(${tHUAQw`1g}2>-dD6Z zboE_0${X=s!$Fwd(8>8tmvRMOh4%DHdA;YTC@_n1M#z3k%BR@(Z`bz3ErA;qrDP|? zF--Q^(3(+=^}a4?A4v+gP5T{ORYyH#o$bWM@jO@tbjVpW;j=h36Fn^%=t^ng3POWX zX@tu57XBQZ7H$iO4A~?ld&LQp9yf9HXdJo?jH>a3U6v%F70%kWlmF9OZ#wt5|NX66 zihqzM;ECoVN#q5E1-u&fJQc9`)CkvV(B%>(fjs1(+f{)zSp#h_gVP+i+T~T3z*ST1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pp b/src/gb/GB.cpp index 55563e56..ff0ba9a0 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -586,12 +586,17 @@ bool gbIsGameboyRom(char * file) void gbCopyMemory(u16 d, u16 s, int count) { - while(count) { - gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff]; - s++; - d++; - count--; - } + if (s>=0xE000 && s<0xFE00) + { + s-=0x2000; + } + while(count) + { + gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff]; + s++; + d++; + count--; + } } void gbDoHdma() @@ -669,10 +674,16 @@ void gbWriteMemory(register u16 address, register u8 value) return; } - if(address < 0xfe00) { - gbMemoryMap[address>>12][address & 0x0fff] = value; - return; - } + if (address<0xE000) + { + gbMemoryMap[address>>12][address & 0x0fff] = value; + return; + } + if(address < 0xfe00) + { + gbMemoryMap[(address-0x2000)>>12][address & 0x0fff] = value; + return; + } if(address < 0xff00) { gbMemory[address] = value; @@ -1155,7 +1166,7 @@ u8 gbReadOpcode(register u16 address) if(gbCheatMap[address]) return gbCheatRead(address); - switch(address & 0xf000) { + switch((address>>12) & 0x000f) { case 0x0a: case 0x0b: if(mapperReadRAM) @@ -1216,7 +1227,10 @@ u8 gbReadOpcode(register u16 address) } break; } - return gbMemoryMap[address>>12][address & 0x0fff]; + if (address>=0xE000 && address<0xFE00) +{ + return gbMemoryMap[(address-0x2000)>>12][address & 0x0fff]; + } } u8 gbReadMemory(register u16 address) @@ -1381,8 +1395,10 @@ u8 gbReadMemory(register u16 address) return register_IE; } } - - return gbMemoryMap[address>>12][address & 0x0fff]; +if (address>=0xE000 && address<0xFE00) + { + return gbMemoryMap[(address-0x2000)>>12][address & 0x0fff]; + } } void gbVblank_interrupt()