diff --git a/src/libretro/freej2me_libretro.c b/src/libretro/freej2me_libretro.c index 4174dd67..ac82941c 100755 --- a/src/libretro/freej2me_libretro.c +++ b/src/libretro/freej2me_libretro.c @@ -144,7 +144,8 @@ char *outPath; /* Actual path of FreeJ2ME's jar to start */ char** params; /* Char matrix containing launch arguments */ unsigned int optstrlen; /* length of the string above */ unsigned long int screenRes[2]; /* {width, height} */ -int rotateScreen; /* acts as a boolean */ +int halveCanvasRes; /* acts as a boolean */ +int rotateScreen; /* also acts as a boolean */ int phoneType; /* 0=standard, 1=nokia, 2=siemens, 3=motorola, 4=sonyEricsson */ int gameFPS; /* Auto(0), 60, 30, 15 */ int soundEnabled; /* also acts as a boolean */ @@ -303,6 +304,14 @@ static void check_variables(bool first_time_startup) } + var.key = "freej2me_halvecanvasres"; + if (Environ(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "off")) { halveCanvasRes = 0; } + else if (!strcmp(var.value, "on")) { halveCanvasRes = 1; } + } + + var.key = "freej2me_rotate"; if (Environ(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { @@ -449,7 +458,7 @@ static void check_variables(bool first_time_startup) /* Prepare a string to pass those core options to the Java app */ options_update = malloc(sizeof(char) * PIPE_MAX_LEN); - snprintf(options_update, PIPE_MAX_LEN, "FJ2ME_LR_OPTS:|%lux%lu|%d|%d|%d|%d|%d|%d|%d", screenRes[0], screenRes[1], rotateScreen, phoneType, gameFPS, soundEnabled, customMidi, maxMidiPlayers, dumpAudioStreams); + snprintf(options_update, PIPE_MAX_LEN, "FJ2ME_LR_OPTS:|%lux%lu|%d|%d|%d|%d|%d|%d|%d|%d", screenRes[0], screenRes[1], halveCanvasRes, rotateScreen, phoneType, gameFPS, soundEnabled, customMidi, maxMidiPlayers, dumpAudioStreams); optstrlen = strlen(options_update); /* 0xD = 13, which is the special case where the java app will receive the updated configs */ @@ -508,9 +517,10 @@ void retro_init(void) */ check_variables(true); - char resArg[2][4], rotateArg[2], phoneArg[2], fpsArg[3], soundArg[2], midiArg[2], maxMidiArg[3], dumpAudioArg[2]; + char resArg[2][4], halveCanvas[2], rotateArg[2], phoneArg[2], fpsArg[3], soundArg[2], midiArg[2], maxMidiArg[3], dumpAudioArg[2]; sprintf(resArg[0], "%lu", screenRes[0]); /* Libretro config Width */ sprintf(resArg[1], "%lu", screenRes[1]); /* Libretro config Height */ + sprintf(halveCanvas, "%d", halveCanvasRes); sprintf(rotateArg, "%d", rotateScreen); sprintf(phoneArg, "%d", phoneType); sprintf(fpsArg, "%d", gameFPS); @@ -536,17 +546,18 @@ void retro_init(void) params[2] = strdup(outPath); params[3] = strdup(resArg[0]); params[4] = strdup(resArg[1]); - params[5] = strdup(rotateArg); - params[6] = strdup(phoneArg); - params[7] = strdup(fpsArg); - params[8] = strdup(soundArg); - params[9] = strdup(midiArg); - params[10] = strdup(maxMidiArg); - params[11] = strdup(dumpAudioArg); - params[12] = NULL; // Null-terminate the array - - log_fn(RETRO_LOG_INFO, "Passing params: %s | %s | %s | %s | %s | %s | %s | %s | %s\n", *(params+3), - *(params+4), *(params+5), *(params+6), *(params+7), *(params+8), *(params+9), *(params+10), *(params+11)); + params[5] = strdup(halveCanvas); + params[6] = strdup(rotateArg); + params[7] = strdup(phoneArg); + params[8] = strdup(fpsArg); + params[9] = strdup(soundArg); + params[10] = strdup(midiArg); + params[11] = strdup(maxMidiArg); + params[12] = strdup(dumpAudioArg); + params[13] = NULL; // Null-terminate the array + + log_fn(RETRO_LOG_INFO, "Passing params: %s | %s | %s | %s | %s | %s | %s | %s | %s | %s\n", *(params+3), + *(params+4), *(params+5), *(params+6), *(params+7), *(params+8), *(params+9), *(params+10), *(params+11), *(params+12)); } log_fn(RETRO_LOG_INFO, "Preparing to open FreeJ2ME-Plus' Java app (make sure freej2me-lr.jar is inside system/).\n"); @@ -1042,8 +1053,8 @@ pid_t javaOpen(char *cmd, char **params) log_fn(RETRO_LOG_INFO, "Setting up java app's process and pipes...\n"); log_fn(RETRO_LOG_INFO, "Opening: %s %s %s ...\n", *(params+0), *(params+1), *(params+2)); - log_fn(RETRO_LOG_INFO, "Params: %s | %s | %s | %s | %s | %s | %s | %s | %s\n", *(params+3), - *(params+4), *(params+5), *(params+6), *(params+7), *(params+8), *(params+9), *(params+10), *(params+11)); + log_fn(RETRO_LOG_INFO, "Params: %s | %s | %s | %s | %s | %s | %s | %s | %s | %s\n", *(params+3), + *(params+4), *(params+5), *(params+6), *(params+7), *(params+8), *(params+9), *(params+10), *(params+11), *(params+12)); } else { log_fn(RETRO_LOG_INFO, "\n\nRESTARTING!!!\n\n"); restarting = false; } @@ -1102,6 +1113,7 @@ bool isRunning(pid_t pid) if(waitpid(pid, &status, WNOHANG) == 0) { return true; } log_fn(RETRO_LOG_INFO, "Java app is not running anymore! Last known PID=%d \n", pid); + exit(0); return false; } #elif _WIN32 @@ -1171,7 +1183,7 @@ void javaOpen(char *cmd, char **params) sprintf(cmdWin, "javaw -jar %s", cmd); log_fn(RETRO_LOG_INFO, "Opening: %s \n", cmd); - for (int i = 3; i <= 11; i++) /* There are 10 cmd arguments for now */ + for (int i = 3; i <= 12; i++) /* There are 10 cmd arguments for now */ { //log_fn(RETRO_LOG_INFO, "Processing arg %d: %s \n", i, *(params+i)); sprintf(cmdWin, "%s %s", cmdWin, *(params+i)); @@ -1184,8 +1196,8 @@ void javaOpen(char *cmd, char **params) log_fn(RETRO_LOG_INFO, "Setting up java app's process and pipes...\n"); log_fn(RETRO_LOG_INFO, "Opening: %s %s %s ...\n", *(params+0), *(params+1), *(params+2)); - log_fn(RETRO_LOG_INFO, "Params: %s | %s | %s | %s | %s | %s | %s | %s | %s\n", *(params+3), - *(params+4), *(params+5), *(params+6), *(params+7), *(params+8), *(params+9), *(params+10), *(params+11)); + log_fn(RETRO_LOG_INFO, "Params: %s | %s | %s | %s | %s | %s | %s | %s | %s | %s\n", *(params+3), + *(params+4), *(params+5), *(params+6), *(params+7), *(params+8), *(params+9), *(params+10), *(params+11), *(params+12)); } else { log_fn(RETRO_LOG_INFO, "\n\nRESTARTING!!!\n\n"); restarting = false; } diff --git a/src/libretro/freej2me_libretro.h b/src/libretro/freej2me_libretro.h index ed577fa8..07926bb5 100644 --- a/src/libretro/freej2me_libretro.h +++ b/src/libretro/freej2me_libretro.h @@ -108,6 +108,20 @@ struct retro_core_option_v2_definition core_options[] = }, "240x320" }, + { + "freej2me_halvecanvasres", + "Virtual Phone Settings > Halve Canvas Res", + "Halve Canvas Res", + "While the 'Phone Resolution' setting follows device screen resolution, some games do, in fact, render at a lower resolution and then upscale to the phone's native res by a factor of 2. A few 352x416 Nokia N80 games do this, as well as Harry Potter and the Deathly Hallows for the Nokia N5800 XpressMusic (360x640). Enabling this will make those games fill the whole screen.", + "While the 'Phone Resolution' setting follows device screen resolution, some games do, in fact, render at a lower resolution and then upscale to the phone's native res by a factor of 2. A few 352x416 Nokia N80 games do this, as well as Harry Potter and the Deathly Hallows for the Nokia N5800 XpressMusic (360x640). Enabling this will make those games fill the whole screen.", + "vphone_settings", + { + { "off", "Disabled" }, + { "on", "Enabled" }, + { NULL, NULL }, + }, + "off" + }, { "freej2me_rotate", "Virtual Phone Settings > Rotate Screen", @@ -375,6 +389,17 @@ struct retro_core_option_definition core_options_v1 [] = }, "240x320" }, + { + "freej2me_halvecanvasres", + "Halve Canvas Res", + "While the 'Phone Resolution' setting follows device screen resolution, some games do, in fact, render at a lower resolution and then upscale to the phone's native res by a factor of 2. A few 352x416 Nokia N80 games do this, as well as Harry Potter and the Deathly Hallows for the Nokia N5800 XpressMusic (360x640). Enabling this will make those games fill the whole screen.", + { + { "off", "Disabled" }, + { "on", "Enabled" }, + { NULL, NULL }, + }, + "off" + }, { "freej2me_rotate", "Rotate Screen", @@ -566,6 +591,10 @@ static const struct retro_variable vars[] = "freej2me_resolution", "Phone Resolution (Core Restart required); 240x320|96x65|101x64|101x80|128x128|130x130|128x142|128x160|132x176|176x204|176x208|176x220|220x176|208x208|208x320|320x240|240x400|240x432|240x480|352x416|360x640|640x360|640x480|480x800|800x480" }, + { /* Screen Rotation */ + "freej2me_halvecanvasres", + "Halve Canvas Res; off|on" + }, { /* Screen Rotation */ "freej2me_rotate", "Rotate Screen; off|on" diff --git a/src/org/recompile/freej2me/AWTGUI.java b/src/org/recompile/freej2me/AWTGUI.java index bde987b1..6b27f9d7 100644 --- a/src/org/recompile/freej2me/AWTGUI.java +++ b/src/org/recompile/freej2me/AWTGUI.java @@ -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); @@ -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) @@ -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); @@ -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")); diff --git a/src/org/recompile/freej2me/Anbu.java b/src/org/recompile/freej2me/Anbu.java index 00fbdc6e..c7b7cbdf 100644 --- a/src/org/recompile/freej2me/Anbu.java +++ b/src/org/recompile/freej2me/Anbu.java @@ -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; @@ -299,20 +298,13 @@ 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; } @@ -320,10 +312,8 @@ private void keyDown(int key) 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; } @@ -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; } diff --git a/src/org/recompile/freej2me/Config.java b/src/org/recompile/freej2me/Config.java index 97d47166..9e160248 100644 --- a/src/org/recompile/freej2me/Config.java +++ b/src/org/recompile/freej2me/Config.java @@ -30,7 +30,6 @@ import java.nio.file.Paths; import java.nio.file.Path; -import javax.microedition.lcdui.Graphics; import javax.microedition.media.Manager; import org.recompile.mobile.Mobile; @@ -40,15 +39,9 @@ public class Config { public boolean isRunning = false; - private PlatformImage lcd; - private Graphics gc; private int width; private int height; - private ArrayList menu; - private int menuid = 0; - private int itemid = 0; - private File file; private String configPath = ""; private String configFile = ""; @@ -61,24 +54,6 @@ public class Config public Config() { - width = Mobile.getPlatform().lcdWidth; - height = Mobile.getPlatform().lcdHeight; - - lcd = new PlatformImage(width, height); - gc = lcd.getGraphics(); - - menu = new ArrayList(); - menu.add(new String[]{"Resume Game", "Display Size", "Sound", "Limit FPS", "Phone", "Rotate", "MIDI", "Max MIDI Streams", "Exit"}); // 0 - Main Menu - menu.add(supportedResolutions); // 1 - Size - menu.add(new String[]{"Quit", "Main Menu"}); // 2 - Restart Notice - menu.add(new String[]{"On", "Off"}); // 3 - sound - menu.add(new String[]{"Standard", "Nokia", "Siemens","Motorola", "SonyEricsson"}); // 4 - Phone - menu.add(new String[]{"On", "Off"}); // 5 - rotate - menu.add(new String[]{"Auto", "60 - Fast", "30 - Slow", "15 - Turtle"}); // 6 - FPS - menu.add(new String[]{"Default", "Custom"}); // 7 - MIDI soundfont - menu.add(new String[]{"1", "2", "4", "8", "16", "32", "48", "64", "96"}); // 8 - Max amount of MIDI Players - - onChange = new Runnable() { public void run() @@ -112,6 +87,7 @@ public void init() file.createNewFile(); settings.put("width", ""+width); settings.put("height", ""+height); + settings.put("halveCanvasRes", "off"); settings.put("sound", "on"); settings.put("phone", "Standard"); settings.put("rotate", "off"); @@ -152,6 +128,7 @@ public void init() } if(!settings.containsKey("width")) { settings.put("width", ""+width); } if(!settings.containsKey("height")) { settings.put("height", ""+height); } + if(!settings.containsKey("halveCanvasRes")) { settings.put("halveCanvasRes", "off"); } if(!settings.containsKey("sound")) { settings.put("sound", "on"); } if(!settings.containsKey("phone")) { settings.put("phone", "Standard"); } if(!settings.containsKey("rotate")) { settings.put("rotate", "off"); } @@ -159,15 +136,6 @@ public void init() if(!settings.containsKey("soundfont")) { settings.put("soundfont", "Default"); } if(!settings.containsKey("maxmidistreams")) { settings.put("maxmidistreams", "32"); } - int w = Integer.parseInt(settings.get("width")); - int h = Integer.parseInt(settings.get("height")); - if(width!=w || height!=h) - { - width = w; - height = h; - lcd = new PlatformImage(width, height); - gc = lcd.getGraphics(); - } } catch (Exception e) { @@ -198,243 +166,6 @@ public void saveConfig() } } - public void start() - { - isRunning = true; - render(); - Mobile.getPlatform().painter.run(); - } - - public void stop() - { - isRunning = false; - Mobile.getPlatform().painter.run(); - } - - public void keyPressed(int key) - { - switch(key) - { - case Mobile.KEY_NUM2: itemid--; break; - case Mobile.KEY_NUM8: itemid++; break; - case Mobile.KEY_NUM5: doMenuAction(); break; - default: - if(settings.get("phone").equals("Nokia") || settings.get("phone").equals("SonyEricsson")) - { - switch(key) - { - case Mobile.NOKIA_UP: itemid--; break; - case Mobile.NOKIA_DOWN: itemid++; break; - case Mobile.NOKIA_SOFT1: menuid=0; break; - case Mobile.NOKIA_SOFT3: doMenuAction(); break; - } - } - if(settings.get("phone").equals("Siemens")) - { - switch(key) - { - case Mobile.SIEMENS_UP: itemid--; break; - case Mobile.SIEMENS_DOWN: itemid++; break; - case Mobile.SIEMENS_SOFT1: menuid=0; break; - case Mobile.SIEMENS_FIRE: doMenuAction(); break; - } - } - if(settings.get("phone").equals("Motorola")) - { - switch(key) - { - case Mobile.MOTOROLA_UP: itemid--; break; - case Mobile.MOTOROLA_DOWN: itemid++; break; - case Mobile.MOTOROLA_SOFT1: menuid=0; break; - case Mobile.MOTOROLA_FIRE: doMenuAction(); break; - } - } - } - if (menuid<0) { menuid=0; itemid=0; } - if (itemid>=menu.get(menuid).length) { itemid = menu.get(menuid).length-1; } - if (itemid<0) { itemid = 0; } - - render(); - } - - public void keyReleased(int key) { } - public void mousePressed(int key) { } - public void mouseReleased(int key) { } - - public BufferedImage getLCD() - { - return lcd.getCanvas(); - } - - public void render() - { - String label; - String title = "Game Options"; - - switch(menuid) - { - case 1: title = "Screen Size"; break; - case 2: title = "Restart Required"; break; - case 3: title = "Sound"; break; - } - - gc.setColor(0x000080); - gc.fillRect(0,0,width,height); - gc.setColor(0xFFFFFF); - gc.drawString(title, width/2, 2, Graphics.HCENTER); - gc.drawLine(0, 20, width, 20); - gc.drawLine(0, height-20, width, height-20); - - /* - gc.setColor(0x00FF00); - gc.drawRect(0, 0, 128, 128); - height = 128; - width = 128; - */ - - if (menuid>0) - { - gc.setColor(0xFFFFFF); - gc.drawString("Back", 3, height-17, Graphics.LEFT); - } - - String[] t = menu.get(menuid); - - int ah = (int)((height-50)/(t.length+1)); - if(ah<15) { ah=15; } - - int space = 0; - if(ah>15) { space = (ah-15) / 2; } - - int max = (int)Math.floor((height-50)/ah); - int page = (int)Math.floor(itemid/max); - int start = (int)(max*page); - int pages = (int)Math.ceil(t.length/max); - - if(pages>=1) - { - gc.setColor(0xFFFFFF); - gc.drawString("Page "+(page+1)+" of "+(pages+1), width-3, height-17, Graphics.RIGHT); - } - - for(int i=start; (i<(start+max))&(i1 && i<8) - { - switch(i) - { - case 2: label = label+": "+settings.get("sound"); break; - case 3: label = label+": "+settings.get("fps"); break; - case 4: label = label+": "+settings.get("phone"); break; - case 5: label = label+": "+settings.get("rotate"); break; - case 6: label = label+": "+settings.get("soundfont"); break; - case 7: label = label+": "+settings.get("maxmidistreams"); break; - } - } - if(i==itemid) - { - gc.setColor(0xFFFF00); - gc.drawString("> "+label+" <", width/2, (25+space)+(ah*(i-start)), Graphics.HCENTER); - } - else - { - gc.setColor(0xFFFFFF); - gc.drawString(label, width/2, (25+space)+(ah*(i-start)), Graphics.HCENTER); - } - } - - Mobile.getPlatform().painter.run(); - } - - private void doMenuAction() - { - switch(menuid) - { - case 0: // Main Menu - switch(itemid) - { - case 0: stop(); break; // resume - case 1: menuid=1; itemid=0; break; // display size - case 2: menuid=3; itemid=0; break; // sound - case 3: menuid=6; itemid=0; break; // fps - case 4: menuid=4; itemid=0; break; // phone - case 5: menuid=5; itemid=0; break; // rotate - case 6: menuid=7; itemid=0; break; // MIDI soundfont - case 7: menuid=10; itemid=0; break; // max MIDI Players - case 8: System.exit(0); break; - } - break; - - case 1: // Display Size - String[] t = menu.get(1)[itemid].split("x"); - - updateDisplaySize(Integer.parseInt(t[0]), Integer.parseInt(t[1])); - - menuid=2; itemid=0; - break; - - case 2: // Restart Required Notice - switch(itemid) - { - case 0: System.exit(0); break; - case 1: menuid=0; itemid=0; - } - break; - - case 3: // Turn Sound On/Off - if(itemid==0) { updateSound("on"); } - if(itemid==1) { updateSound("off"); } - menuid=0; itemid=0; - break; - - case 4: // Switch Phone Mode - if(itemid==0) { updatePhone("Standard"); } - if(itemid==1) { updatePhone("Nokia"); } - if(itemid==2) { updatePhone("Siemens"); } - if(itemid==3) { updatePhone("Motorola"); } - if(itemid==4) { updatePhone("SonyEricsson"); } - menuid=0; itemid=0; - break; - - case 5: // Turn Rotation On/Off - if(itemid==0) { updateRotate("on"); } - if(itemid==1) { updateRotate("off"); } - menuid=0; itemid=0; - break; - - case 6: // FPS - if(itemid==0) { updateFPS("0"); } - if(itemid==1) { updateFPS("60"); } - if(itemid==2) { updateFPS("30"); } - if(itemid==3) { updateFPS("15"); } - menuid=0; itemid=0; - break; - - case 7: // Set MIDI Soundfont to System default or custom file - if(itemid==0) { updateSoundfont("Default"); } - if(itemid==1) { updateSoundfont("Custom"); } - menuid=2; itemid=0; - break; - - case 8: // Max Midi Streams - if(itemid==0) { updateMIDIStreams("1"); } - if(itemid==1) { updateMIDIStreams("2"); } - if(itemid==2) { updateMIDIStreams("4"); } - if(itemid==3) { updateMIDIStreams("8"); } - if(itemid==4) { updateMIDIStreams("16"); } - if(itemid==5) { updateMIDIStreams("32"); } - if(itemid==6) { updateMIDIStreams("48"); } - if(itemid==7) { updateMIDIStreams("64"); } - if(itemid==8) { updateMIDIStreams("96"); } - menuid=2; itemid=0; - break; - - } - - render(); - } - public void updateDisplaySize(int w, int h) { settings.put("width", ""+w); @@ -443,9 +174,15 @@ public void updateDisplaySize(int w, int h) onChange.run(); width = w; height = h; - lcd = new PlatformImage(width, height); - gc = lcd.getGraphics(); + } + public void updateCanvasScale(String value) + { + System.out.println("Config: Halve Canvas Resolution "+value); + settings.put("halveCanvasRes", value); + + saveConfig(); + onChange.run(); } public void updateSound(String value) diff --git a/src/org/recompile/freej2me/FreeJ2ME.java b/src/org/recompile/freej2me/FreeJ2ME.java index aa667791..17eeb2d8 100644 --- a/src/org/recompile/freej2me/FreeJ2ME.java +++ b/src/org/recompile/freej2me/FreeJ2ME.java @@ -220,22 +220,15 @@ public void keyPressed(KeyEvent e) return; } - if(config.isRunning) + if (pressedKeys[mobikeyN] == false) { - config.keyPressed(mobikey); + //~ System.out.println("keyPressed: " + Integer.toString(mobikey)); + Mobile.getPlatform().keyPressed(mobikey); } else { - if (pressedKeys[mobikeyN] == false) - { - //~ System.out.println("keyPressed: " + Integer.toString(mobikey)); - Mobile.getPlatform().keyPressed(mobikey); - } - else - { - //~ System.out.println("keyRepeated: " + Integer.toString(mobikey)); - Mobile.getPlatform().keyRepeated(mobikey); - } + //~ System.out.println("keyRepeated: " + Integer.toString(mobikey)); + Mobile.getPlatform().keyRepeated(mobikey); } pressedKeys[mobikeyN] = true; } @@ -255,15 +248,8 @@ public void keyReleased(KeyEvent e) pressedKeys[mobikeyN] = false; - if(config.isRunning) - { - config.keyReleased(mobikey); - } - else - { - //~ System.out.println("keyReleased: " + Integer.toString(mobikey)); - Mobile.getPlatform().keyReleased(mobikey); - } + //~ System.out.println("keyReleased: " + Integer.toString(mobikey)); + Mobile.getPlatform().keyReleased(mobikey); } } @@ -427,6 +413,8 @@ private void settingsChanged() if(midiSoundfont.equals("Custom")) { PlatformPlayer.customMidi = true; } else if(midiSoundfont.equals("Default")) { PlatformPlayer.customMidi = false; } + if(config.settings.get("halveCanvasRes").equals("on")) { w /= 2; h /= 2; } + // Create a standard size LCD if not rotated, else invert window's width and height. if(!rotateDisplay) { @@ -573,26 +561,14 @@ public void update(Graphics g) { public void paint(Graphics g) { - if (config.isRunning) - { - if(!rotateDisplay) { g.drawImage(config.getLCD(), cx, cy, cw, ch, null); } - else - { - // If rotated, simply redraw the config menu with different width and height - g.drawImage(config.getLCD(), cy, cx, cw, ch, null); - } - } + if(!rotateDisplay) { g.drawImage(Mobile.getPlatform().getLCD(), cx, cy, cw, ch, null); } else { - if(!rotateDisplay) { g.drawImage(Mobile.getPlatform().getLCD(), cx, cy, cw, ch, null); } - else - { - final Graphics2D cgc = (Graphics2D)this.getGraphics(); - // Rotate the FB 90 degrees counterclockwise with an adjusted pivot - cgc.rotate(Math.toRadians(-90), ch/2, ch/2); - // Draw the rotated FB with adjusted cy and cx values - cgc.drawImage(Mobile.getPlatform().getLCD(), 0, cx, ch, cw, null); - } + final Graphics2D cgc = (Graphics2D)this.getGraphics(); + // Rotate the FB 90 degrees counterclockwise with an adjusted pivot + cgc.rotate(Math.toRadians(-90), ch/2, ch/2); + // Draw the rotated FB with adjusted cy and cx values + cgc.drawImage(Mobile.getPlatform().getLCD(), 0, cx, ch, cw, null); } } } diff --git a/src/org/recompile/freej2me/Libretro.java b/src/org/recompile/freej2me/Libretro.java index 7af3bc3a..26dfba42 100644 --- a/src/org/recompile/freej2me/Libretro.java +++ b/src/org/recompile/freej2me/Libretro.java @@ -48,6 +48,7 @@ public class Libretro private boolean useNokiaControls = false; private boolean useSiemensControls = false; private boolean useMotorolaControls = false; + private boolean halveCanvasRes = false; private boolean rotateDisplay = false; private boolean soundEnabled = true; @@ -119,24 +120,26 @@ public Libretro(String args[]) lcdWidth = Integer.parseInt(args[0]); lcdHeight = Integer.parseInt(args[1]); - if(Integer.parseInt(args[2]) == 1) { rotateDisplay = true; } + if(Integer.parseInt(args[2]) == 1) { halveCanvasRes = true; } - if(Integer.parseInt(args[3]) == 1) { useNokiaControls = true; Mobile.nokia = true; } - else if(Integer.parseInt(args[3]) == 2) { useSiemensControls = true; Mobile.siemens = true; } - else if(Integer.parseInt(args[3]) == 3) { useMotorolaControls = true; Mobile.motorola = true; } - else if(Integer.parseInt(args[3]) == 4) { useNokiaControls = true; Mobile.sonyEricsson = true; } + if(Integer.parseInt(args[3]) == 1) { rotateDisplay = true; } - limitFPS = Integer.parseInt(args[4]); + if(Integer.parseInt(args[4]) == 1) { useNokiaControls = true; Mobile.nokia = true; } + else if(Integer.parseInt(args[4]) == 2) { useSiemensControls = true; Mobile.siemens = true; } + else if(Integer.parseInt(args[4]) == 3) { useMotorolaControls = true; Mobile.motorola = true; } + else if(Integer.parseInt(args[4]) == 4) { useNokiaControls = true; Mobile.sonyEricsson = true; } - if(Integer.parseInt(args[5]) == 0) { soundEnabled = false; } + limitFPS = Integer.parseInt(args[5]); - if(Integer.parseInt(args[6]) == 1) { PlatformPlayer.customMidi = true; } + if(Integer.parseInt(args[6]) == 0) { soundEnabled = false; } + + if(Integer.parseInt(args[7]) == 1) { PlatformPlayer.customMidi = true; } - maxmidistreams = Integer.parseInt(args[7]); + maxmidistreams = Integer.parseInt(args[8]); Manager.updatePlayerNum((byte) maxmidistreams); /* Dump Audio Streams will not be a per-game FreeJ2ME config, so it will have to be set every time for now */ - if(Integer.parseInt(args[8]) == 1) { Manager.dumpAudioStreams = true; } + if(Integer.parseInt(args[9]) == 1) { Manager.dumpAudioStreams = true; } /* Once it finishes parsing all arguments, it's time to set up freej2me-lr */ @@ -306,6 +309,9 @@ public void run() config.settings.put("width", ""+lcdWidth); config.settings.put("height", ""+lcdHeight); + if(halveCanvasRes) { config.settings.put("halveCanvasRes", "on"); } + if(!halveCanvasRes) { config.settings.put("halveCanvasRes", "off"); } + if(rotateDisplay) { config.settings.put("rotate", "on"); } if(!rotateDisplay) { config.settings.put("rotate", "off"); } @@ -368,34 +374,37 @@ public void run() config.settings.put("width", ""+Integer.parseInt(cfgtokens[1])); config.settings.put("height", ""+Integer.parseInt(cfgtokens[2])); - if(Integer.parseInt(cfgtokens[3])==1) { config.settings.put("rotate", "on"); } - if(Integer.parseInt(cfgtokens[3])==0) { config.settings.put("rotate", "off"); } + if(Integer.parseInt(cfgtokens[3])==1) { config.settings.put("halveCanvasRes", "on"); } + if(Integer.parseInt(cfgtokens[3])==0) { config.settings.put("halveCanvasRes", "off"); } + + if(Integer.parseInt(cfgtokens[4])==1) { config.settings.put("rotate", "on"); } + if(Integer.parseInt(cfgtokens[4])==0) { config.settings.put("rotate", "off"); } - if(Integer.parseInt(cfgtokens[4])==0) { config.settings.put("phone", "Standard"); } - if(Integer.parseInt(cfgtokens[4])==1) { config.settings.put("phone", "Nokia"); } - if(Integer.parseInt(cfgtokens[4])==2) { config.settings.put("phone", "Siemens"); } - if(Integer.parseInt(cfgtokens[4])==3) { config.settings.put("phone", "Motorola"); } + if(Integer.parseInt(cfgtokens[5])==0) { config.settings.put("phone", "Standard"); } + if(Integer.parseInt(cfgtokens[5])==1) { config.settings.put("phone", "Nokia"); } + if(Integer.parseInt(cfgtokens[5])==2) { config.settings.put("phone", "Siemens"); } + if(Integer.parseInt(cfgtokens[5])==3) { config.settings.put("phone", "Motorola"); } - config.settings.put("fps", ""+cfgtokens[5]); + config.settings.put("fps", ""+cfgtokens[6]); - if(Integer.parseInt(cfgtokens[6])==1) { config.settings.put("sound", "on"); } - if(Integer.parseInt(cfgtokens[6])==0) { config.settings.put("sound", "off"); } + if(Integer.parseInt(cfgtokens[7])==1) { config.settings.put("sound", "on"); } + if(Integer.parseInt(cfgtokens[7])==0) { config.settings.put("sound", "off"); } - if(Integer.parseInt(cfgtokens[7])==0) { config.settings.put("soundfont", "Default"); } - if(Integer.parseInt(cfgtokens[7])==1) { config.settings.put("soundfont", "Custom"); } + if(Integer.parseInt(cfgtokens[8])==0) { config.settings.put("soundfont", "Default"); } + if(Integer.parseInt(cfgtokens[8])==1) { config.settings.put("soundfont", "Custom"); } - if(Integer.parseInt(cfgtokens[8])==0) { config.settings.put("maxmidistreams", "1");} - if(Integer.parseInt(cfgtokens[8])==1) { config.settings.put("maxmidistreams", "2");} - if(Integer.parseInt(cfgtokens[8])==2) { config.settings.put("maxmidistreams", "4");} - if(Integer.parseInt(cfgtokens[8])==3) { config.settings.put("maxmidistreams", "8");} - if(Integer.parseInt(cfgtokens[8])==4) { config.settings.put("maxmidistreams", "16");} - if(Integer.parseInt(cfgtokens[8])==5) { config.settings.put("maxmidistreams", "32");} - if(Integer.parseInt(cfgtokens[8])==6) { config.settings.put("maxmidistreams", "48");} - if(Integer.parseInt(cfgtokens[8])==7) { config.settings.put("maxmidistreams", "64");} - if(Integer.parseInt(cfgtokens[8])==8) { config.settings.put("maxmidistreams", "96");} + if(Integer.parseInt(cfgtokens[9])==0) { config.settings.put("maxmidistreams", "1");} + if(Integer.parseInt(cfgtokens[9])==1) { config.settings.put("maxmidistreams", "2");} + if(Integer.parseInt(cfgtokens[9])==2) { config.settings.put("maxmidistreams", "4");} + if(Integer.parseInt(cfgtokens[9])==3) { config.settings.put("maxmidistreams", "8");} + if(Integer.parseInt(cfgtokens[9])==4) { config.settings.put("maxmidistreams", "16");} + if(Integer.parseInt(cfgtokens[9])==5) { config.settings.put("maxmidistreams", "32");} + if(Integer.parseInt(cfgtokens[9])==6) { config.settings.put("maxmidistreams", "48");} + if(Integer.parseInt(cfgtokens[9])==7) { config.settings.put("maxmidistreams", "64");} + if(Integer.parseInt(cfgtokens[9])==8) { config.settings.put("maxmidistreams", "96");} - if(Integer.parseInt(cfgtokens[9])==1) { Manager.dumpAudioStreams = true; } - if(Integer.parseInt(cfgtokens[9])==0) { Manager.dumpAudioStreams = false; } + if(Integer.parseInt(cfgtokens[10])==1) { Manager.dumpAudioStreams = true; } + if(Integer.parseInt(cfgtokens[10])==0) { Manager.dumpAudioStreams = false; } config.saveConfig(); settingsChanged(); @@ -407,14 +416,8 @@ public void run() { final int[] data; - if(config.isRunning) - { - data = config.getLCD().getRGB(0, 0, lcdWidth, lcdHeight, null, 0, lcdWidth); - } - else - { - data = surface.getRGB(0, 0, lcdWidth, lcdHeight, null, 0, lcdWidth); - } + data = surface.getRGB(0, 0, lcdWidth, lcdHeight, null, 0, lcdWidth); + final int bufferLength = data.length*3; int cb = 0; for(int i=0; i