@@ -20,6 +20,8 @@ function GameBoyAdvance() {
2020 this . keypad = new GameBoyAdvanceKeypad ( ) ;
2121 this . sio = new GameBoyAdvanceSIO ( ) ;
2222
23+ this . frozenAddresses = { } ;
24+
2325 // TODO: simplify this graph
2426 this . cpu . mmu = this . mmu ;
2527 this . cpu . irq = this . irq ;
@@ -71,6 +73,14 @@ function GameBoyAdvance() {
7173
7274window . GameBoyAdvance = GameBoyAdvance
7375
76+ GameBoyAdvance . prototype . addFreezeAddress = function ( { address, size, value } ) {
77+ this . frozenAddresses [ address ] = { size, value } ;
78+ } ;
79+
80+ GameBoyAdvance . prototype . removeFreezeAddress = function ( address ) {
81+ delete this . frozenAddresses [ address ] ;
82+ } ;
83+
7484GameBoyAdvance . prototype . setCanvas = function ( canvas ) {
7585 var self = this ;
7686 if ( canvas . offsetWidth != 240 || canvas . offsetHeight != 160 ) {
@@ -144,8 +154,26 @@ GameBoyAdvance.prototype.reset = function() {
144154} ;
145155
146156GameBoyAdvance . prototype . step = function ( ) {
157+ const mmuMemoryIram = this . mmu . memory [ this . mmu . REGION_WORKING_IRAM ] ;
158+
147159 while ( this . doStep ( ) ) {
148160 this . cpu . step ( ) ;
161+
162+ for ( const address in this . frozenAddresses ) {
163+ const { size, value } = this . frozenAddresses [ address ] ;
164+
165+ switch ( size ) {
166+ case 8 :
167+ mmuMemoryIram . store8 ( address , value ) ;
168+ break ;
169+ case 16 :
170+ mmuMemoryIram . store16 ( address , value ) ;
171+ break ;
172+ case 16 :
173+ mmuMemoryIram . store32 ( address , value ) ;
174+ break ;
175+ }
176+ }
149177 }
150178} ;
151179
0 commit comments