This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified backgrounds to cache their tilemaps/character data and only update it if the vram actually changes Actually commit the change to dump backgrounds correctly
- Loading branch information
1 parent
a8c0c26
commit 279f4e1
Showing
4 changed files
with
208 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package edu.fit.cs.sno.snes.mem; | ||
|
||
import java.util.HashSet; | ||
|
||
public abstract class MemoryObserver { | ||
public static HashSet<MemoryObserver> observers = new HashSet<MemoryObserver>(); | ||
public static boolean addObserver(MemoryObserver o) { | ||
return observers.add(o); | ||
} | ||
public static boolean delObserver(MemoryObserver o) { | ||
return observers.remove(o); | ||
} | ||
public static void notifyObservers(int address) { | ||
for(MemoryObserver o: observers) { | ||
int[] range = o.getRange(); | ||
for(int i=0;i<range.length; i+=2) { | ||
int start = range[i]; | ||
int end = range[i+1]; | ||
if (address >= start && address <= end) { | ||
o.onInvalidate(address); | ||
break; // Move on to the next observer | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Declares the range of memory addresses we want to watch and be notified when they change | ||
* @return list of start/end values for memory ranges | ||
*/ | ||
public abstract int[] getRange(); | ||
|
||
/** | ||
* Called when the memory is changed(passed a list of addresses that have been modified) | ||
* @param addr - A list of addresses that changed | ||
*/ | ||
public abstract void onInvalidate(int addr); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters