Mercurial > vba-clojure
diff src/gb/GB.cpp @ 92:1ff2c546f5ad
added tick(), which allows one to step through each opcode of gameboy
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 11 Mar 2012 19:07:31 -0500 |
parents | d7c38ce83421 |
children | 4c60ebca1a9d |
line wrap: on
line diff
1.1 --- a/src/gb/GB.cpp Sun Mar 11 13:53:27 2012 -0500 1.2 +++ b/src/gb/GB.cpp Sun Mar 11 19:07:31 2012 -0500 1.3 @@ -15,7 +15,7 @@ 1.4 #include "../common/Util.h" 1.5 #include "../common/System.h" 1.6 #include "../common/movie.h" 1.7 -#include "../common/vbalua.h" 1.8 +// #include "../common/vbalua.h" 1.9 1.10 #ifdef __GNUC__ 1.11 #define _stricmp strcasecmp 1.12 @@ -1280,7 +1280,7 @@ 1.13 void gbWriteMemory(register u16 address, register u8 value) 1.14 { 1.15 gbWriteMemoryWrapped(address, value); 1.16 - CallRegisteredLuaMemHook(address, 1, value, LUAMEMHOOK_WRITE); 1.17 + //CallRegisteredLuaMemHook(address, 1, value, LUAMEMHOOK_WRITE); 1.18 } 1.19 1.20 u8 gbReadMemory(register u16 address) 1.21 @@ -3164,8 +3164,9 @@ 1.22 return true; 1.23 } 1.24 1.25 -void gbEmulate(int ticksToStop) 1.26 +int gbEmulate(int ticksToStop) 1.27 { 1.28 + int rlm_count = 0; 1.29 //printf("RLM: Inside the GB!\n"); 1.30 gbRegister tempRegister; 1.31 u8 tempValue; 1.32 @@ -3232,8 +3233,8 @@ 1.33 } 1.34 1.35 1.36 - for (;; ) 1.37 - { 1.38 + //for (;; ) 1.39 + // { 1.40 #ifndef FINAL_VERSION 1.41 if (systemDebug) 1.42 { 1.43 @@ -3276,7 +3277,8 @@ 1.44 else 1.45 { 1.46 opcode = gbReadOpcode(PC.W); 1.47 - CallRegisteredLuaMemHook(PC.W, 1, opcode, LUAMEMHOOK_EXEC); 1.48 + //printf("RLM: calling mem Hook ; %07d\n", rlm_count++); 1.49 + //CallRegisteredLuaMemHook(PC.W, 1, opcode, LUAMEMHOOK_EXEC); 1.50 PC.W++; 1.51 1.52 if (IFF & 0x100) 1.53 @@ -3304,7 +3306,7 @@ 1.54 } 1.55 1.56 if (!emulating) 1.57 - return; 1.58 + return 1; 1.59 1.60 if (gbDmaTicks) 1.61 { 1.62 @@ -3774,31 +3776,31 @@ 1.63 if ((gbInterrupt & 1) && (register_IE & 1)) 1.64 { 1.65 gbVblank_interrupt(); 1.66 - continue; 1.67 + return newFrame; 1.68 } 1.69 1.70 if ((gbInterrupt & 2) && (register_IE & 2)) 1.71 { 1.72 gbLcd_interrupt(); 1.73 - continue; 1.74 + return newFrame; 1.75 } 1.76 1.77 if ((gbInterrupt & 4) && (register_IE & 4)) 1.78 { 1.79 gbTimer_interrupt(); 1.80 - continue; 1.81 + return newFrame; 1.82 } 1.83 1.84 if ((gbInterrupt & 8) && (register_IE & 8)) 1.85 { 1.86 gbSerial_interrupt(); 1.87 - continue; 1.88 + return newFrame; 1.89 } 1.90 1.91 if ((gbInterrupt & 16) && (register_IE & 16)) 1.92 { 1.93 gbJoypad_interrupt(); 1.94 - continue; 1.95 + return newFrame; 1.96 } 1.97 } 1.98 } 1.99 @@ -3814,12 +3816,12 @@ 1.100 { 1.101 // old timing code 1.102 if (ticksToStop > 0) 1.103 - continue; 1.104 + return newFrame; 1.105 } 1.106 else 1.107 { 1.108 if (!newFrame && (register_LCDC & 0x80) != 0) 1.109 - continue; 1.110 + return newFrame; 1.111 } 1.112 1.113 if (!(register_LCDC & 0x80)) 1.114 @@ -3862,14 +3864,15 @@ 1.115 } 1.116 1.117 // makes sure frames are really divided across input sampling boundaries which occur at a constant rate 1.118 - if (newFrame || useOldFrameTiming) 1.119 - { 1.120 + //if (newFrame || useOldFrameTiming) 1.121 + // { 1.122 /// extern void VBAOnEnteringFrameBoundary(); 1.123 /// VBAOnEnteringFrameBoundary(); 1.124 1.125 - break; 1.126 - } 1.127 - } 1.128 + // break; 1.129 + // } 1.130 + // RLM removing for loop } 1.131 + return newFrame; 1.132 } 1.133 1.134 1.135 @@ -3964,7 +3967,7 @@ 1.136 gbWriteSaveState, 1.137 // emuReadStateFromStream 1.138 gbReadSaveStateFromStream, 1.139 - // emuWriteStateToStream 1.140 + // emuwritestatetostream 1.141 gbWriteSaveStateToStream, 1.142 // emuReadMemState 1.143 gbReadMemSaveState,