Skip to content

Commit

Permalink
Config: Drop interactive menu, and add option to halve canvas res
Browse files Browse the repository at this point in the history
Some games for Nokia N80 actually run at 176x208 and are then scaled
to the phone's native 352x416 screen res. The same happens with
some Nokia 5800 XpressMusic games such as Harry Potter and the Deathly
Hallows, where the game itself renders at 180x320, and then scales
to the phones actual 360x640 screen. Since screen resolutions should
mirror phones and not game shenanigans, i think making this a
toggle instead of adding two new resolutions makes more sense.

At least until FreeJ2ME gets a comprehensive function to automatically
scale these without user intervention.
  • Loading branch information
AShiningRay committed Sep 28, 2024
1 parent ab8369b commit 2a57081
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 351 deletions.
12 changes: 12 additions & 0 deletions src/org/recompile/freej2me/AWTGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public final class AWTGUI
final CheckboxMenuItem enableAudio = new CheckboxMenuItem("Enable Audio", false);
final CheckboxMenuItem enableRotation = new CheckboxMenuItem("Rotate Screen", false);
final CheckboxMenuItem useCustomMidi = new CheckboxMenuItem("Use custom midi soundfont", false);
final CheckboxMenuItem halveCanvasRes = new CheckboxMenuItem("Halve Canvas Resolution", false);

final CheckboxMenuItem stdLayout = new CheckboxMenuItem("Standard", true);
final CheckboxMenuItem nokiaLayout = new CheckboxMenuItem("Nokia", false);
Expand Down Expand Up @@ -399,6 +400,15 @@ public void itemStateChanged(ItemEvent e)
}
});

halveCanvasRes.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(halveCanvasRes.getState()){ config.updateCanvasScale("on"); hasPendingChange = true; }
else{ config.updateCanvasScale("off"); hasPendingChange = true; }
}
});

midiStreams[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
Expand Down Expand Up @@ -798,6 +808,7 @@ private void buildMenuBar()
optionMenu.add(enableRotation);
optionMenu.add(useCustomMidi);
optionMenu.add(resChangeMenuItem);
optionMenu.add(halveCanvasRes);
optionMenu.add(phoneType);
optionMenu.add(fpsCap);
optionMenu.add(midiStreamNum);
Expand Down Expand Up @@ -832,6 +843,7 @@ public void updateOptions()
enableAudio.setState(config.settings.get("sound").equals("on"));
enableRotation.setState(config.settings.get("rotate").equals("on"));
useCustomMidi.setState(config.settings.get("soundfont").equals("Custom"));
halveCanvasRes.setState(config.settings.get("halveCanvasRes").equals("on"));
fpsCapNone.setState(config.settings.get("fps").equals("0"));
fpsCap15.setState(config.settings.get("fps").equals("15"));
fpsCap30.setState(config.settings.get("fps").equals("30"));
Expand Down
24 changes: 7 additions & 17 deletions src/org/recompile/freej2me/Anbu.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public void run()
int[] data;

// Send Frame to SDL interface
if(!config.isRunning) { data = Mobile.getPlatform().getLCD().getRGB(0, 0, lcdWidth, lcdHeight, null, 0, lcdWidth); }
else { data = config.getLCD().getRGB(0, 0, lcdWidth, lcdHeight, null, 0, lcdWidth);}
data = Mobile.getPlatform().getLCD().getRGB(0, 0, lcdWidth, lcdHeight, null, 0, lcdWidth);
byte[] frame = new byte[data.length * 3];
int cb = 0;

Expand Down Expand Up @@ -299,31 +298,22 @@ public void run()
private void keyDown(int key)
{
int mobikeyN = (key + 64) & 0x7F; //Normalized value for indexing the pressedKeys array
if(config.isRunning)
if (pressedKeys[mobikeyN] == false)
{
config.keyPressed(key);
Mobile.getPlatform().keyPressed(key);
}
else
{
if (pressedKeys[mobikeyN] == false)
{
Mobile.getPlatform().keyPressed(key);
}
else
{
Mobile.getPlatform().keyRepeated(key);
}
Mobile.getPlatform().keyRepeated(key);
}
pressedKeys[mobikeyN] = true;
}

private void keyUp(int key)
{
int mobikeyN = (key + 64) & 0x7F; //Normalized value for indexing the pressedKeys array
if(!config.isRunning)
{
Mobile.getPlatform().keyReleased(key);
}

Mobile.getPlatform().keyReleased(key);
pressedKeys[mobikeyN] = false;
}

Expand Down Expand Up @@ -395,7 +385,7 @@ else if(useMotorolaControls)

//if(keycode == 0x0F) return Mobile.GAME_C; // Screenshot, shouldn't really be used here

if(keycode == 0x1B) { config.start(); } // ESC, special key to bring up the config menu
//if(keycode == 0x1B) { config.start(); } // ESC, special key to bring up the config menu

return 0;
}
Expand Down
Loading

0 comments on commit 2a57081

Please sign in to comment.