- Messages
- 15
- Reaction score
- 0
- Points
- 16
Help mga experts gusto ko sanang baguhin yung code ng meboy para pwede ako mag asign ng keys sa center button ng dpad kaso lang di ko alam kung panu. Sana meron makatulong eto po ang sourcecode ng meboy in GBcanvas.class
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class GBCanvas extends Canvas implements CommandListener {
public MeBoy parent;
private Dmgcpu cpu;
private int w, h, l, t;
private int sw, sh, trans; // translation, and screen size (on screen, i.e. scaled and rotated if applicable)
private int ssw, ssh; // source screen width and height (possibly scaled, not rotated)
private int clipHeight; // maybe including fps
private int[] previousTime = new int[16];
private int previousTimeIx;
private Command pauseCommand = new Command(MeBoy.literal[30], Command.SCREEN, 0);
private Command resumeCommand = new Command(MeBoy.literal[31], Command.SCREEN, 2);
private Command saveCommand = new Command(MeBoy.literal[32], Command.SCREEN, 1);
private Command showFpsCommand = new Command(MeBoy.literal[33], Command.SCREEN, 3);
private Command fullScreenCommand = new Command(MeBoy.literal[34], Command.SCREEN, 4);
private Command setButtonsCommand = new Command(MeBoy.literal[35], Command.SCREEN, 5);
private Command exitCommand;
private static int[] key = new int[] {KEY_NUM6, KEY_NUM4, KEY_NUM2, KEY_NUM8, KEY_NUM7, KEY_NUM9, KEY_POUND, KEY_STAR};
private String[] keyName = {
MeBoy.literal[38],
MeBoy.literal[39],
MeBoy.literal[40],
MeBoy.literal[41],
MeBoy.literal[42],
MeBoy.literal[43],
MeBoy.literal[44],
MeBoy.literal[45]};
private int keySetCounter;
private boolean settingKeys;
private boolean paused;
private String cartDisplayName;
private String cartID = "";
private String cartFileName;
private String suspendName;
private Thread cpuThread;
// Common constructor
private GBCanvas(MeBoy p, String cartFileName, String cartDisplayName) {
parent = p;
this.cartFileName = cartFileName;
this.cartDisplayName = cartDisplayName;
exitCommand = new Command(MeBoy.literal[36] + " " + cartDisplayName, Command.SCREEN, 6);
setCommandListener(this);
updateCommands();
setFullScreenMode(MeBoy.fullScreen);
}
// Constructor for loading suspended games
public GBCanvas(String cartID, String cartFileName, MeBoy p, String cartDisplayName,
String suspendName, byte[] suspendState) {
this(p, cartFileName, cartDisplayName);
this.suspendName = suspendName;
cpu = new Dmgcpu(cartFileName, this, suspendState);
setDimensions();
cpuThread = new Thread(cpu);
cpuThread.start();
}
// Constructor for new games
public GBCanvas(String cartFileName, MeBoy p, String cartDisplayName) {
this(p, cartFileName, cartDisplayName);
cpu = new Dmgcpu(cartFileName, this);
if (cpu.hasBattery())
loadCartRam();
setDimensions();
cpuThread = new Thread(cpu);
cpuThread.start();
}
private void updateCommands() {
// remove and add all commands, to prevent pause/resume to end up last
removeCommand(pauseCommand);
removeCommand(resumeCommand);
removeCommand(saveCommand);
removeCommand(showFpsCommand);
removeCommand(fullScreenCommand);
removeCommand(setButtonsCommand);
removeCommand(exitCommand);
if (paused)
addCommand(resumeCommand);
else
addCommand(pauseCommand);
addCommand(saveCommand);
addCommand(showFpsCommand);
addCommand(fullScreenCommand);
addCommand(setButtonsCommand);
addCommand(exitCommand);
}
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class GBCanvas extends Canvas implements CommandListener {
public MeBoy parent;
private Dmgcpu cpu;
private int w, h, l, t;
private int sw, sh, trans; // translation, and screen size (on screen, i.e. scaled and rotated if applicable)
private int ssw, ssh; // source screen width and height (possibly scaled, not rotated)
private int clipHeight; // maybe including fps
private int[] previousTime = new int[16];
private int previousTimeIx;
private Command pauseCommand = new Command(MeBoy.literal[30], Command.SCREEN, 0);
private Command resumeCommand = new Command(MeBoy.literal[31], Command.SCREEN, 2);
private Command saveCommand = new Command(MeBoy.literal[32], Command.SCREEN, 1);
private Command showFpsCommand = new Command(MeBoy.literal[33], Command.SCREEN, 3);
private Command fullScreenCommand = new Command(MeBoy.literal[34], Command.SCREEN, 4);
private Command setButtonsCommand = new Command(MeBoy.literal[35], Command.SCREEN, 5);
private Command exitCommand;
private static int[] key = new int[] {KEY_NUM6, KEY_NUM4, KEY_NUM2, KEY_NUM8, KEY_NUM7, KEY_NUM9, KEY_POUND, KEY_STAR};
private String[] keyName = {
MeBoy.literal[38],
MeBoy.literal[39],
MeBoy.literal[40],
MeBoy.literal[41],
MeBoy.literal[42],
MeBoy.literal[43],
MeBoy.literal[44],
MeBoy.literal[45]};
private int keySetCounter;
private boolean settingKeys;
private boolean paused;
private String cartDisplayName;
private String cartID = "";
private String cartFileName;
private String suspendName;
private Thread cpuThread;
// Common constructor
private GBCanvas(MeBoy p, String cartFileName, String cartDisplayName) {
parent = p;
this.cartFileName = cartFileName;
this.cartDisplayName = cartDisplayName;
exitCommand = new Command(MeBoy.literal[36] + " " + cartDisplayName, Command.SCREEN, 6);
setCommandListener(this);
updateCommands();
setFullScreenMode(MeBoy.fullScreen);
}
// Constructor for loading suspended games
public GBCanvas(String cartID, String cartFileName, MeBoy p, String cartDisplayName,
String suspendName, byte[] suspendState) {
this(p, cartFileName, cartDisplayName);
this.suspendName = suspendName;
cpu = new Dmgcpu(cartFileName, this, suspendState);
setDimensions();
cpuThread = new Thread(cpu);
cpuThread.start();
}
// Constructor for new games
public GBCanvas(String cartFileName, MeBoy p, String cartDisplayName) {
this(p, cartFileName, cartDisplayName);
cpu = new Dmgcpu(cartFileName, this);
if (cpu.hasBattery())
loadCartRam();
setDimensions();
cpuThread = new Thread(cpu);
cpuThread.start();
}
private void updateCommands() {
// remove and add all commands, to prevent pause/resume to end up last
removeCommand(pauseCommand);
removeCommand(resumeCommand);
removeCommand(saveCommand);
removeCommand(showFpsCommand);
removeCommand(fullScreenCommand);
removeCommand(setButtonsCommand);
removeCommand(exitCommand);
if (paused)
addCommand(resumeCommand);
else
addCommand(pauseCommand);
addCommand(saveCommand);
addCommand(showFpsCommand);
addCommand(fullScreenCommand);
addCommand(setButtonsCommand);
addCommand(exitCommand);
}
Last edited: