Today we continue on our quest to make a small VGA game. So far we learned how to initialize Mode X and use some of its nice features. Copying images from system memory was painfully slow though. So let’s make it faster with a small trick!
Tag: coding
Let’s Code ESP8266 0x02: CO2 sensor CCS811
Let’s Code MS DOS 0x07: Game Over!
Let’s Code MS DOS 0x04: Make It Move!
Let’s Code MS DOS 0x02: The Keyboard
Let’s Code MS DOS 0x01: Hello World!
Indexed Java 8 enums with gaps
This is an example enum for Java 8 that supports gaps in its indices is relatively fast for enums with a large amount of values:
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
public enum TestEnum {
VALUE1( 0 ),
VALUE2( 2 ),
VALUE3( 50 );
private final Integer id_;
private static Map< Integer, TestEnum > values_ =
Arrays.stream( TestEnum.values() ).collect( Collectors.toMap(e -> e.id_, e -> e) );;
private TestEnum( int i ) { id_ = i; }
public static TestEnum fromInteger( int i )
{
return values_.get( i );
}
}