diff --git a/build.sh b/build.sh index 50219f1..c2e6823 100644 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ set -e # Exit immediately if any command fails MAIN_CLASS="dothack/DotHack.java" -PROJECT_NAME="dh_musicfix" +PROJECT_NAME="dh" SOURCE_PATH="src" PATH_LIBRARIES="lib" PATH_PROGUARD="/home/sillysagiri/Documents/dothack/proguard.jar" @@ -28,4 +28,4 @@ jar cvfm "build/${PROJECT_NAME}_not_preverified.jar" "${SOURCE_PATH}/META-INF/MA java -jar $PATH_PROGUARD -microedition -injars "build/${PROJECT_NAME}_not_preverified.jar" -outjars "build/${PROJECT_NAME}.jar" -libraryjars $CLASSPATH -dontshrink -dontoptimize -dontobfuscate -target $CLASS_VERSION # release build -# java -jar $PATH_PROGUARD -microedition -injars "build/${PROJECT_NAME}_not_preverified.jar" -outjars "build/${PROJECT_NAME}_release.jar" -libraryjars $CLASSPATH -target $CLASS_VERSION -keep "class * extends javax.microedition.midlet.MIDlet" -optimizationpasses 4 -repackageclasses "" -allowaccessmodification \ No newline at end of file +java -jar $PATH_PROGUARD -microedition -injars "build/${PROJECT_NAME}_not_preverified.jar" -outjars "build/${PROJECT_NAME}_release.jar" -libraryjars $CLASSPATH -target $CLASS_VERSION -keep "class * extends javax.microedition.midlet.MIDlet" -repackageclasses "" \ No newline at end of file diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF index 72f2c88..eb0be2a 100644 --- a/src/META-INF/MANIFEST.MF +++ b/src/META-INF/MANIFEST.MF @@ -1,10 +1,12 @@ Manifest-Version: 1.0 -MicroEdition-Configuration: CLDC-1.0 -MIDlet-Description: MeNet21 -MIDlet-Version: 1.0.0 -Created-By: 1.3.0_02(Sun Microsystems Inc.) -MIDlet-Vendor: MeNet21 -MicroEdition-Profile: MIDP-1.0 MIDlet-1: 닷핵,/logo/menet.png,dothack.DotHack +MIDlet-Vendor: MeNet21 +MIDlet-Info-URL: http://java.sun.com/j2me MIDlet-Name: 닷핵 -MIDlet-Info-URL: http://java.sun.com/j2me/ +MIDlet-Description: MeNet21 +MIDlet-Version: 1.2 +MicroEdition-Configuration: CLDC-1.1 +MicroEdition-Profile: MIDP-2.0 +Sagiri-Note: music converted to pcm and removed LG MMAPI dependency +Sagiri-URL: https://sillysagiri.moe + diff --git a/src/dothack/DotHack.java b/src/dothack/DotHack.java index c1d70cc..80c63a7 100644 --- a/src/dothack/DotHack.java +++ b/src/dothack/DotHack.java @@ -23,15 +23,10 @@ public class DotHack extends MIDlet implements Runnable { _display.setCurrent(game); thread = new Thread(this); - thread.setPriority(Thread.MAX_PRIORITY); + // thread.setPriority(Thread.MAX_PRIORITY); thread.start(); - try { - sagiri.Set_Scene(new Intro()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + sagiri.Set_Scene(new Intro()); } public void pauseApp() {} @@ -40,20 +35,17 @@ public class DotHack extends MIDlet implements Runnable { public void run() { while (true) { - try - { - sagiri.time_begin = System.currentTimeMillis(); + sagiri.time_begin = System.currentTimeMillis(); + + try { Thread.sleep(1000/sagiri.fps); } + catch (Exception e) {} + + game.repaint(); + game.serviceRepaints(); - game.repaint(); - game.serviceRepaints(); - Thread.sleep(1000/sagiri.fps); - - sagiri.time_delta = System.currentTimeMillis() - sagiri.time_begin; - } - catch (Exception e) - { - // TODO: catch any unhandled exception here - } + sagiri.input.Update(); + + sagiri.time_delta = System.currentTimeMillis() - sagiri.time_begin; } } } \ No newline at end of file diff --git a/src/dothack/DotHackC.java b/src/dothack/DotHackC.java index c5f5626..0791469 100644 --- a/src/dothack/DotHackC.java +++ b/src/dothack/DotHackC.java @@ -133,7 +133,7 @@ public class DotHackC extends Canvas { public DotHackC(DotHack app) { setFullScreenMode(true); midlet = app; - sagiri = app.sagiri; + sagiri = Sagiri._instance; bG = Image.createImage(120, 133); bgG = bG.getGraphics(); @@ -151,27 +151,27 @@ public class DotHackC extends Canvas { sagiri.Update(g); } - protected void keyPressed(int keycode) + public final void keyPressed(int keyCode) { - sagiri.input.HandleKeyDown(keycode); + sagiri.input.HandleKeyDown(keyCode); } - protected void keyReleased(int keycode) + public final void keyReleased(int keyCode) { - sagiri.input.HandleKeyUp(keycode); + sagiri.input.HandleKeyUp(keyCode); } - protected void pointerPressed(int x, int y) + public final void pointerPressed(int x, int y) { sagiri.input.HandleTouch(Sagiri.TOUCH_BEGIN, x, y); } - protected void pointerReleased(int x, int y) + public final void pointerReleased(int x, int y) { sagiri.input.HandleTouch(Sagiri.TOUCH_END, x, y); } - protected void pointerDragged(int x, int y) + public final void pointerDragged(int x, int y) { sagiri.input.HandleTouch(Sagiri.TOUCH_DRAG, x, y); } @@ -238,7 +238,7 @@ public class DotHackC extends Canvas { this.useK = 0; } - public void paint2(Graphics g) { + /* public void paint2(Graphics g) { // probably to render bellow device built-in ui // doesnt need this anymore since midp2.0 allow to do fullscreen // if (getHeight() == 143) @@ -2474,7 +2474,7 @@ public class DotHackC extends Canvas { } } catch (Exception exception) {} } - + */ public void infoWinPaint(int paramInt1, String paramString1, String paramString2, int paramInt2, int paramInt3, int paramInt4, int paramInt5, Image paramImage, Graphics paramGraphics) { paramGraphics.drawImage(paramImage, paramInt2, paramInt3, 20); paramGraphics.setColor(255, 0, 0); diff --git a/src/sillysagiri/BMF.java b/src/sillysagiri/BMF.java index f4cf3bf..43eda4f 100644 --- a/src/sillysagiri/BMF.java +++ b/src/sillysagiri/BMF.java @@ -22,10 +22,30 @@ public class BMF { public short base; public short[][] chars; - public BMF(String path_img, String path_fnt) throws Exception + public BMF() { - img = Image.createImage(path_img); + } + public static final BMF Create(String path_img, String path_fnt) throws Exception + { + BMF bmf = new BMF(); + bmf.img = Image.createImage(path_img); + bmf.Parse_fnt(path_fnt); + + return bmf; + } + + public static final BMF Create(Image img, String path_fnt) throws Exception + { + BMF bmf = new BMF(); + bmf.img = img; + bmf.Parse_fnt(path_fnt); + + return bmf; + } + + protected void Parse_fnt(String path_fnt) throws Exception + { InputStream in = this.getClass().getResourceAsStream(path_fnt); byte[] header = new byte[4]; @@ -126,6 +146,25 @@ public class BMF { } } + /* + * this is cpu intensive process + * consider creating new BMF for each color instead + * + * limitation: + * currently can only be used once + * since its replacing white pixel with tinted color + */ + public void SetColor(int rgb) + { + int[] buffer = new int[img.getWidth()*img.getHeight()]; + img.getRGB(buffer, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); + + for (int i=0; i= 600) counter = 0; if (counter < 400) - g.drawImage( - img_ez, - Utils.GetScreenWidth()/2, (int)(Utils.GetScreenHeight()*0.75), + bmf_outline.DrawEx(g, + "PRESS ANY KEY", + Utils.GetScreenWidth()/2, (int)(Utils.GetScreenHeight()*0.7), Graphics.VCENTER | Graphics.HCENTER); if (sagiri.input.IsKeyDownAny()) - { sagiri.Set_Scene(new MainMenu()); - } } break; diff --git a/src/sillysagiri/scene/MainMenu.java b/src/sillysagiri/scene/MainMenu.java index bf03e00..80326f7 100644 --- a/src/sillysagiri/scene/MainMenu.java +++ b/src/sillysagiri/scene/MainMenu.java @@ -15,15 +15,13 @@ public class MainMenu extends Scene { private Image img_bg; private Image img_bandai; - private Image img_ez; private BMF bmf; public void Preload() { try { - bmf = new BMF("/silly/bmf/nds12.png", "/silly/bmf/nds12.fnt"); + bmf = BMF.Create("/silly/bmf/onds12_0.png", "/silly/bmf/onds12.fnt"); Image img_loop = Image.createImage("/m_2.png"); img_bandai = Image.createImage("/c_0.png"); - img_ez = Image.createImage("/pEZ.png"); int loopCount = (int)Math.ceil((float)Utils.GetScreenHeight()/img_loop.getHeight()); @@ -60,13 +58,11 @@ public class MainMenu extends Scene { if (counter >= 600) counter = 0; if (counter < 400) - g.drawImage( - img_ez, - Utils.GetScreenWidth()/2, (int)(Utils.GetScreenHeight()*0.75), + bmf.DrawEx(g, + "PRESS ANY KEY", + Utils.GetScreenWidth()/2, (int)(Utils.GetScreenHeight()*0.7), Graphics.VCENTER | Graphics.HCENTER); - bmf.Draw(g, "hello world\nthis is test text!\nthe fox jumped over the lazy dog", 5, 10); - if (sagiri.input.IsKeyDownAny()) { counter = 0;