Skip to content

Commit

Permalink
helios: perf tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Berti committed Dec 2, 2022
1 parent d0806f6 commit 86a98d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
23 changes: 4 additions & 19 deletions src/main/java/omegadrive/vdp/md/VdpScrollHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@

package omegadrive.vdp.md;

import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Maps;
import omegadrive.vdp.model.InterlaceMode;
import omegadrive.vdp.model.RenderPriority;
import omegadrive.vdp.model.VdpMemoryInterface;
import omegadrive.vdp.model.VdpMisc.RenderType;

import java.util.EnumSet;
import java.util.Map;

//A horizontal scroll mode setting of 01b is not valid; however the unlicensed version
// of Populous uses it. This mode is identical to per-line scrolling, however
// the VDP will only read the first sixteen entries in the scroll table for
Expand Down Expand Up @@ -105,41 +100,31 @@ enum HSCROLL {
LINE(0b11),
INVALID(0b01);

private static final Map<Integer, HSCROLL> lookup = ImmutableBiMap.copyOf(
Maps.toMap(EnumSet.allOf(HSCROLL.class), HSCROLL::getRegValue)).inverse();
private static final HSCROLL[] lookupRegValue = {SCREEN, INVALID, CELL, LINE};
private final int regValue;

HSCROLL(int regValue) {
this.regValue = regValue;
}

public static HSCROLL getHScrollType(int regValue) {
return lookup.get(regValue);
}

public int getRegValue() {
return regValue;
return lookupRegValue[regValue];
}
}

enum VSCROLL {
SCREEN(0),
TWO_CELLS(1);

private static final Map<Integer, VSCROLL> lookup = ImmutableBiMap.copyOf(
Maps.toMap(EnumSet.allOf(VSCROLL.class), VSCROLL::getRegValue)).inverse();
private static final VSCROLL[] lookupRegValue = {SCREEN, TWO_CELLS};
private final int regValue;

VSCROLL(int regValue) {
this.regValue = regValue;
}

public static VSCROLL getVScrollType(int regValue) {
return lookup.get(regValue);
}

public int getRegValue() {
return regValue;
return lookupRegValue[regValue];
}
}
}
10 changes: 2 additions & 8 deletions src/main/java/omegadrive/vdp/model/GenesisVdpProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@

package omegadrive.vdp.model;

import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Maps;
import omegadrive.bus.model.GenesisBusProvider;
import omegadrive.util.LogHelper;
import omegadrive.vdp.md.GenesisVdp;
import omegadrive.vdp.md.VdpFifo;
import org.slf4j.Logger;

import java.util.EnumSet;
import java.util.Map;

public interface GenesisVdpProvider extends BaseVdpProvider {

Logger LOG = LogHelper.getLogger(GenesisVdpProvider.class.getSimpleName());
Expand Down Expand Up @@ -140,11 +135,10 @@ enum VdpRegisterName {
DMA_SOURCE_HIGH //23 - 0x17
;

private static final Map<Integer, VdpRegisterName> lookup = ImmutableBiMap.copyOf(
Maps.toMap(EnumSet.allOf(VdpRegisterName.class), VdpRegisterName::ordinal)).inverse();
private static final VdpRegisterName[] lookup = VdpRegisterName.values();

public static VdpRegisterName getRegisterName(int index) {
return lookup.get(index);
return lookup[index];
}
}

Expand Down
13 changes: 3 additions & 10 deletions src/main/java/omegadrive/vdp/model/InterlaceMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@

package omegadrive.vdp.model;

import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Maps;

import java.util.EnumSet;
import java.util.Map;

public enum InterlaceMode {
NONE,
MODE_1,
INVALID,
MODE_2(1);

public static final InterlaceMode[] lookup = InterlaceMode.values();

private int tileShift = 5;
private int verticalScrollShift = 0;
private int verticalCellPixelSize = 8;
Expand All @@ -48,11 +44,8 @@ public enum InterlaceMode {
this.tileIndexMask = 0xFFFF - interlaceAdjust;
}

private static final Map<Integer, InterlaceMode> lookup = ImmutableBiMap.copyOf(
Maps.toMap(EnumSet.allOf(InterlaceMode.class), InterlaceMode::ordinal)).inverse();

public static InterlaceMode getInterlaceMode(int index) {
return lookup.get(index);
return lookup[index];
}

public int tileShift() {
Expand Down

0 comments on commit 86a98d7

Please sign in to comment.