Compare commits

...

7 Commits

22 changed files with 630 additions and 172 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
build
build
ideas.txt

View File

@ -1,6 +1,7 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"vendor/**/*.jar",
"library/tinygzip/tinylinegzip.jar"
],
"java.project.sourcePaths": [
"src"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Binary file not shown.

View File

@ -1,31 +0,0 @@
#!/bin/bash
set -e # Exit immediately if any command fails
MAIN_CLASS="dothack/DotHack.java"
PROJECT_NAME="dh_musicfix"
SOURCE_PATH="src"
PATH_LIBRARIES="lib"
PATH_PROGUARD="/home/sillysagiri/Documents/dothack/proguard.jar"
CLASS_VERSION="1.4"
###
rm -rf "build"
mkdir -p "build/class"
###
CLASSPATH=$(find "$PATH_LIBRARIES" -type f | tr '\n' ':' | sed 's/:$//')
# compile class
javac -source $CLASS_VERSION -target $CLASS_VERSION -cp $CLASSPATH -encoding "utf-8" -d "build/class" -sourcepath $SOURCE_PATH -Xlint:-options -g "${SOURCE_PATH}/${MAIN_CLASS}"
# pack .jar
jar cvfm "build/${PROJECT_NAME}_not_preverified.jar" "${SOURCE_PATH}/META-INF/MANIFEST.MF" -C "build/class" . -C "assets" .
# preverify
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

110
build.xml Normal file
View File

@ -0,0 +1,110 @@
<project name="dothack">
<property file="config.properties"/>
<taskdef resource="antenna.properties" classpath="${antenna.path}"/>
<target name="clean">
<delete dir="build"/>
</target>
<target name="debug">
<mkdir dir="build/classes_debug"/>
<wtkbuild
includeAntRuntime="false"
destdir="build/classes_debug"
srcdir="src"
source="1.4"
target="1.4"
debug="true"
preverify="false"
classpath="${midlet.lib}">
<compilerarg value="-Xlint:-options"/>
</wtkbuild>
<wtkjad
jadfile="build/${project.name}_debug.jad"
name="${project.name}"
vendor="${project.vendor}"
version="${project.version}">
<midlet
name="${midlet.name}"
class="${midlet.class}">
</midlet>
</wtkjad>
<wtkpackage
jarfile="build/${project.name}_debug.jar"
jadfile="build/${project.name}_debug.jad"
libclasspath="${midlet.lib}"
obfuscate="true"
preverify="false">
<!-- include -->
<fileset dir="build/classes_debug"/>
<fileset dir="assets"/>
<!-- using proguard to preverify -->
<argument value="-microedition"/>
<!-- proguard args -->
<argument value="-dontshrink -dontoptimize -dontobfuscate -target 1.4"/>
</wtkpackage>
</target>
<target name="release">
<mkdir dir="build/classes_release"/>
<wtkbuild
includeAntRuntime="false"
destdir="build/classes_release"
srcdir="src"
source="1.4"
target="1.4"
debug="false"
preverify="false"
classpath="${midlet.lib}">
<compilerarg value="-Xlint:-options"/>
</wtkbuild>
<wtkjad
jadfile="build/${project.name}_release.jad"
name="${project.name}"
vendor="${project.vendor}"
version="${project.version}">
<midlet
name="${midlet.name}"
class="${midlet.class}">
</midlet>
</wtkjad>
<wtkpackage
jarfile="build/${project.name}_release.jar"
jadfile="build/${project.name}_release.jad"
libclasspath="${midlet.lib}"
obfuscate="true"
preverify="false">
<!-- include -->
<fileset dir="build/classes_release"/>
<fileset dir="assets"/>
<!-- using proguard to preverify -->
<argument value="-microedition"/>
<!-- proguard args -->
<argument value="-target 1.4 -keep 'class * extends javax.microedition.midlet.MIDlet' -repackageclasses '' -optimizationpasses 4 -allowaccessmodification"/>
</wtkpackage>
</target>
</project>

87
config.properties Normal file
View File

@ -0,0 +1,87 @@
## sdk & tools
antenna.path=/home/sillysagiri/Documents/antenna/antenna-bin-1.2.1-beta.jar
wtk.home=/home/sillysagiri/Documents/wtk/
wtk.proguard.home=/home/sillysagiri/Documents/proguard-7.6.0/
# ======================================================== #
## project
project.name=dothack-allscreen
project.vendor=sillysagiri
project.manifest=MANIFEST.MF
project.version=1.0.0
## midlet
midlet.name=dothack
midlet.class=dothack.DotHack
## Specify library here (separated by `;` )
midlet.lib=library/tinygzip/tinylinegzip.jar
## Preprocessor
symbols=
# ======================================================== #
## WTK Properties
## Specifies the version of CLDC to use.
wtk.cldc.version=1.1
## Specifies the version of MIDP to use.
wtk.midp.version=2.0
## Enables or disables the Multimedia API (MMAPI).
wtk.mmapi.enabled=true
## Enables or disables the Wireless Messaging API (WMA) 1.0 (JSR-120).
# wtk.wma.enabled true
## Enables or disables the Wireless Messaging API (WMA) 2.0 (JSR-205).
# wtk.wma2.enabled=true
## Enables or disables the J2ME Web Services API (J2MEWS).
# wtk.j2mews.enabled=true
## Enables or disables the J2ME Bluetooth API (JSR-82).
# wtk.bluetooth.enabled=true
## Enables or disables the J2ME 3D API (JSR-184).
# wtk.java3d.enabled=true
## Enables or disables the J2ME optional PDA packages (JSR-75).
# wtk.optionalpda.enabled=true
## Enables or disables the J2ME location services API (JSR-179).
# wtk.locationservices.enabled=true
## Enables or disables the J2ME content handler API (JSR-211).
# wtk.contenthandler.enabled=true
## Enables or disables the J2ME Security and Trust Services API (JSR-177).
# wtk.satsa.enabled=true
## Enables or disables the J2ME Mobile Internationalization API (JSR-238).
# wtk.miapi.enabled=true
## Enables or disables the J2ME Advanced Multimedia Supplements API (JSR-234).
# wtk.ams.enabled=true
## Enables or disables the J2ME Payment API (JSR-229).
# wtk.papi.enabled=true
## Enables or disables the J2ME Scalable 2D Vector Graphics API (JSR-226).
# wtk.s2dvgapi.enabled=true
## Enables or disables the J2ME Session Initiation Protocol API (JSR-180).
# wtk.sipapi.enabled=true
## Enables all additional libraries (except for CLDC and MIDP) defined for your toolkit.
# wtk.all.enabled=true
## Sets a totally custom BOOTCLASSPATH. Use this property if the set of APIs you need is not covered by the above properties (for example because you are using the system libraries provided another vendor or you have some important additional libraries).
# wtk.midpapi=Varies
# ======================================================== #

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,178 @@
<!DOCTYPE html>
<html>
<head>
<title>Wayback Machine</title>
<script src="//archive.org/includes/analytics.js?v=cf34f82" type="text/javascript"></script>
<script type="text/javascript">window.addEventListener('DOMContentLoaded',function(){var v=archive_analytics.values;v.service='wb';v.server_name='wwwb-app209.us.archive.org';v.server_ms=1023;archive_analytics.send_pageview({});});</script>
<script type="text/javascript" src="/_static/js/bundle-playback.js?v=aToEIw17" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="/_static/css/banner-styles.css?v=omkqRugM" />
<link rel="stylesheet" type="text/css" href="/_static/css/iconochive.css?v=qtvMKcIJ" />
<script src="/_static/js/jquery-1.11.1.min.js"></script>
</head>
<body style="overflow:hidden;">
<!-- BEGIN WAYBACK TOOLBAR INSERT -->
<style type="text/css">
body {
margin-top:0 !important;
padding-top:0 !important;
/*min-width:800px !important;*/
}
</style>
<script>__wm.rw(0);</script>
<div id="wm-ipp-base" lang="en" style="display:none;direction:ltr;">
<div id="wm-ipp" style="position:fixed;left:0;top:0;right:0;">
<div id="wm-ipp-inside">
<div style="position:relative;">
<div id="wm-logo" style="float:left;width:110px;padding-top:12px;">
<a href="/web/" title="Wayback Machine home page"><img src="/_static/images/toolbar/wayback-toolbar-logo-200.png" srcset="/_static/images/toolbar/wayback-toolbar-logo-100.png, /_static/images/toolbar/wayback-toolbar-logo-150.png 1.5x, /_static/images/toolbar/wayback-toolbar-logo-200.png 2x" alt="Wayback Machine" style="width:100px" border="0" /></a>
</div>
<div class="r" style="float:right;">
<div id="wm-btns" style="text-align:right;height:25px;">
<div id="wm-save-snapshot-success">success</div>
<div id="wm-save-snapshot-fail">fail</div>
<a id="wm-save-snapshot-open" href="#"
title="Share via My Web Archive" >
<span class="iconochive-web"></span>
</a>
<a href="https://archive.org/account/login.php"
title="Sign In"
id="wm-sign-in"
>
<span class="iconochive-person"></span>
</a>
<span id="wm-save-snapshot-in-progress" class="iconochive-web"></span>
<a href="http://faq.web.archive.org/" title="Get some help using the Wayback Machine" style="top:-6px;"><span class="iconochive-question" style="color:rgb(87,186,244);font-size:160%;"></span></a>
<a id="wm-tb-close" href="#close" onclick="__wm.h(event);return false;" style="top:-2px;" title="Close the toolbar"><span class="iconochive-remove-circle" style="color:#888888;font-size:240%;"></span></a>
</div>
<div id="wm-share">
<a href="/web/20130928025608/http://web.archive.org/screenshot/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT"
id="wm-screenshot"
title="screenshot">
<span class="wm-icon-screen-shot"></span>
</a>
<a href="#"
id="wm-video"
title="video">
<span class="iconochive-movies"></span>
</a>
<a id="wm-share-facebook" href="#" data-url="https://web.archive.org/web/20130928025608/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="Share on Facebook" style="margin-right:5px;" target="_blank"><span class="iconochive-facebook" style="color:#3b5998;font-size:160%;"></span></a>
<a id="wm-share-twitter" href="#" data-url="https://web.archive.org/web/20130928025608/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="Share on Twitter" style="margin-right:5px;" target="_blank"><span class="iconochive-twitter" style="color:#1dcaff;font-size:160%;"></span></a>
</div>
</div>
<table class="c" style="">
<tbody>
<tr>
<td class="u" colspan="2">
<form target="_top" method="get" action="/web/submit" name="wmtb" id="wmtb"><input type="text" name="url" id="wmtbURL" value="http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT" onfocus="this.focus();this.select();" /><input type="hidden" name="type" value="replay" /><input type="hidden" name="date" value="20130928025608" /><input type="submit" value="Go" /></form>
</td>
<td class="n" rowspan="2" style="width:110px;">
<table>
<tbody>
<!-- NEXT/PREV MONTH NAV AND MONTH INDICATOR -->
<tr class="m">
<td class="b" nowrap="nowrap"><a href="https://web.archive.org/web/20130405235344/http://www.tinyline.com:80/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="05 Apr 2013"><strong>Apr</strong></a></td>
<td class="c" id="displayMonthEl" title="You are here: 02:56:08 Sep 28, 2013">SEP</td>
<td class="f" nowrap="nowrap"><a href="https://web.archive.org/web/20140129040857/http://www.tinyline.com:80/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="29 Jan 2014"><strong>Jan</strong></a></td>
</tr>
<!-- NEXT/PREV CAPTURE NAV AND DAY OF MONTH INDICATOR -->
<tr class="d">
<td class="b" nowrap="nowrap"><a href="https://web.archive.org/web/20130405235344/http://www.tinyline.com:80/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="23:53:44 Apr 05, 2013"><img src="/_static/images/toolbar/wm_tb_prv_on.png" alt="Previous capture" width="14" height="16" border="0" /></a></td>
<td class="c" id="displayDayEl" style="width:34px;font-size:24px;white-space:nowrap;" title="You are here: 02:56:08 Sep 28, 2013">28</td>
<td class="f" nowrap="nowrap"><a href="https://web.archive.org/web/20140129040857/http://www.tinyline.com:80/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="04:08:57 Jan 29, 2014"><img src="/_static/images/toolbar/wm_tb_nxt_on.png" alt="Next capture" width="14" height="16" border="0" /></a></td>
</tr>
<!-- NEXT/PREV YEAR NAV AND YEAR INDICATOR -->
<tr class="y">
<td class="b" nowrap="nowrap"><a href="https://web.archive.org/web/20120923121807/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="23 Sep 2012"><strong>2012</strong></a></td>
<td class="c" id="displayYearEl" title="You are here: 02:56:08 Sep 28, 2013">2013</td>
<td class="f" nowrap="nowrap">2014</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="s">
<div id="wm-nav-captures">
<a class="t" href="/web/20130928025608*/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT" title="See a list of every capture for this URL">38 captures</a>
<div class="r" title="Timespan for captures of this URL">23 Feb 2004 - 29 Jan 2014</div>
</div>
</td>
<td class="k">
<a href="" id="wm-graph-anchor">
<div id="wm-ipp-sparkline" title="Explore captures for this URL" style="position: relative">
<canvas id="wm-sparkline-canvas" width="650" height="27" border="0"></canvas>
</div>
</a>
</td>
</tr>
</tbody>
</table>
<div style="position:absolute;bottom:0;right:2px;text-align:right;">
<a id="wm-expand" class="wm-btn wm-closed" href="#expand" onclick="__wm.ex(event);return false;"><span id="wm-expand-icon" class="iconochive-down-solid"></span> <span style="font-size:80%">About this capture</span></a>
</div>
</div>
<div id="wm-capinfo" style="border-top:1px solid #777;display:none; overflow: hidden">
<div id="wm-capinfo-collected-by">
<div style="background-color:#666;color:#fff;font-weight:bold;text-align:center">COLLECTED BY</div>
<div style="padding:3px;position:relative" id="wm-collected-by-content">
<div style="display:inline-block;vertical-align:top;width:50%;">
<span class="c-logo" style="background-image:url(https://archive.org/services/img/webwidecrawl);"></span>
Organization: <a style="color:#33f;" href="https://archive.org/details/webwidecrawl" target="_new"><span class="wm-title">Internet Archive</span></a>
<div style="max-height:75px;overflow:hidden;position:relative;">
<div style="position:absolute;top:0;left:0;width:100%;height:75px;background:linear-gradient(to bottom,rgba(255,255,255,0) 0%,rgba(255,255,255,0) 90%,rgba(255,255,255,255) 100%);"></div>
The Internet Archive discovers and captures web pages through many different web crawls.
At any given time several distinct crawls are running, some for months, and some every day or longer.
View the web archive through the <a href="http://archive.org/web/web.php">Wayback Machine</a>.
</div>
</div>
<div style="display:inline-block;vertical-align:top;width:49%;">
<span class="c-logo" style="background-image:url(https://archive.org/services/img/wide00009)"></span>
<div>Collection: <a style="color:#33f;" href="https://archive.org/details/wide00009" target="_new"><span class="wm-title">Wide Crawl started August 2013</span></a></div>
<div style="max-height:75px;overflow:hidden;position:relative;">
<div style="position:absolute;top:0;left:0;width:100%;height:75px;background:linear-gradient(to bottom,rgba(255,255,255,0) 0%,rgba(255,255,255,0) 90%,rgba(255,255,255,255) 100%);"></div>
Web wide crawl with initial seedlist and crawler configuration from August 2013.
</div>
</div>
</div>
</div>
<div id="wm-capinfo-timestamps">
<div style="background-color:#666;color:#fff;font-weight:bold;text-align:center" title="Timestamps for the elements of this page">TIMESTAMPS</div>
<div>
<div id="wm-capresources" style="margin:0 5px 5px 5px;max-height:250px;overflow-y:scroll !important"></div>
<div id="wm-capresources-loading" style="text-align:left;margin:0 20px 5px 5px;display:none"><img src="/_static/images/loading.gif" alt="loading" /></div>
</div>
</div>
</div></div></div></div><div id="wm-ipp-print">The Wayback Machine - https://web.archive.org/web/20130928025608/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT</div>
<div id="donato" style="position:relative;width:100%;">
<div id="donato-base">
<iframe id="donato-if" src="https://archive.org/includes/donate.php?as_page=1&amp;platform=wb&amp;referer=https%3A//web.archive.org/web/20130928025608/http%3A//www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT"
scrolling="no" frameborder="0" style="width:100%; height:100%">
</iframe>
</div>
</div><script type="text/javascript">
__wm.bt(650,27,25,2,"web","http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT","20130928025608",1996,"/_static/",["/_static/css/banner-styles.css?v=omkqRugM","/_static/css/iconochive.css?v=qtvMKcIJ"], false);
__wm.rw(1);
</script>
<!-- END WAYBACK TOOLBAR INSERT --><iframe id="playback" src="https://web.archive.org/web/20130928025608if_/http://www.tinyline.com/utils/tinylinegzip/TINYLINE_LICENSE.TXT" frameborder="0" style="position:absolute;top:65px;left:0;width:100%;">
</iframe>
<script type="text/javascript">
var margin_top = 65;
function fitPlayback() {
$('#playback').css({
height: (window.innerHeight - margin_top) + 'px',
top: margin_top
});
}
fitPlayback();
$(window).on('resize', function() {
fitPlayback();
});
$('#wm-tb-close').click(function(){
margin_top = 0;
fitPlayback();
});
</script>
</body>
</html>

Binary file not shown.

View File

@ -1,10 +0,0 @@
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-Name: 닷핵
MIDlet-Info-URL: http://java.sun.com/j2me/

View File

@ -26,12 +26,7 @@ public class DotHack extends MIDlet implements Runnable {
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();
game.repaint();
game.serviceRepaints();
game.repaint();
game.serviceRepaints();
Thread.sleep(1000/sagiri.fps);
sagiri.input.Update();
sagiri.time_delta = System.currentTimeMillis() - sagiri.time_begin;
}
catch (Exception e)
{
// TODO: catch any unhandled exception here
}
try { Thread.sleep(1000/sagiri.fps); }
catch (Exception e) {}
sagiri.time_delta = System.currentTimeMillis() - sagiri.time_begin;
}
}
}

View File

@ -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);

View File

@ -1,11 +1,14 @@
package sillysagiri;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
import sillysagiri.scene.DeathError;
public class BMF {
public static final byte ID = 0;
public static final byte X = 1;
@ -22,10 +25,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 +149,76 @@ 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<buffer.length; i++)
// {
// if (buffer[i] == 0xFF000000) buffer[i] = rgb;
// else buffer[i] = 0x00000000;
// }
try
{
// ByteArrayOutputStream out = new ByteArrayOutputStream(128*64);
// Gzip.gunzip(this.getClass().getResourceAsStream("/silly/bmf/nds12_0.silly.gz"), out);
// GZIPInputStream in = new GZIPInputStream(this.getClass().getResourceAsStream("/silly/bmf/nds12_0.silly.gz"));
InputStream in = this.getClass().getResourceAsStream("/silly/bmf/nds12_0.silly");
int[] buffer = new int[128*64];
// read header
byte[] size = new byte[4];
in.read(size, 0, 4);
int pointer = 0;
while(true)
{
byte[] temp = new byte[2];
int res = in.read(temp, 0, 2);
if (res == -1) break;
char i = (char)((temp[1] << 8) | temp[0]);
// Extract 5-bit ABGR;
char alpha = (char)((i >> 15) & 0x01);
char blue = (char)((i >> 10) & 0x1F);
char green = (char)((i >> 5) & 0x1F);
char red = (char)(i & 0x1F);
// Scale the 5-bit values to 8-bit
if (alpha == 1) alpha = 255;
else alpha = 0;
red = (char)((red << 3) | 0x07);
blue = (char)((green << 3) | 0x07);
green = (char)((blue << 3) | 0x07);
// Combine into 24-bit value AARRGGBB
buffer[pointer] = (alpha << 24) | (red << 16) | (green << 8) | blue;
pointer++;
}
// img = Image.createRGBImage(buffer, img.getWidth(), img.getHeight(), true);
img = Image.createRGBImage(buffer, 128, 64, true);
}
catch(Exception e)
{
e.printStackTrace();
Sagiri._instance.Set_Scene(new DeathError(e));
}
}
// TODO: handle multiline
public short[] Measure(String str)
{
@ -206,4 +299,58 @@ public class BMF {
}
}
public void DrawEx(Graphics g, String str, int x, int y, int anchor)
{
short[] rect = Measure(str);
switch (anchor) {
case (Graphics.TOP | Graphics.LEFT):
Draw(g, str, x, y);
break;
case (Graphics.TOP | Graphics.RIGHT):
Draw(g, str, x-rect[0], y);
break;
case (Graphics.BOTTOM | Graphics.LEFT):
Draw(g, str, x, y-rect[1]);
break;
case (Graphics.BOTTOM | Graphics.RIGHT):
Draw(g, str, x-rect[0], y-rect[1]);
break;
case (Graphics.VCENTER | Graphics.LEFT):
Draw(g, str, x, y-(rect[1]/2));
break;
case (Graphics.VCENTER | Graphics.RIGHT):
Draw(g, str, x-rect[0], y-(rect[1]/2));
break;
case (Graphics.TOP | Graphics.HCENTER):
Draw(g, str, x-(rect[0]/2), y);
break;
case (Graphics.BOTTOM | Graphics.HCENTER):
Draw(g, str, x-(rect[0]/2), y-rect[1]);
break;
case (Graphics.VCENTER | Graphics.HCENTER):
Draw(g, str, x-(rect[0]/2), y-(rect[1]/2));
break;
case (Graphics.BASELINE | Graphics.LEFT):
Draw(g, str, x, y+(lineHeight-base));
break;
case (Graphics.BASELINE | Graphics.RIGHT):
Draw(g, str, x-rect[0], y+(lineHeight-base));
break;
default:
Draw(g, str, x, y);
break;
}
}
}

View File

@ -1,60 +1,30 @@
package sillysagiri;
import java.util.Enumeration;
import java.util.Hashtable;
public final class Input {
public Hashtable hash_keyState = new Hashtable(20);
public int state_anyKey = 0;
public int state_keycode = Sagiri.KEY_NONE;
public int state_keyphase = 0;
public int state_touchState = Sagiri.TOUCH_NONE;
public int state_lastKey = 0;
public int touchX = 0;
public int touchY = 0;
public Input()
{
}
public final void Update()
{
Enumeration i = hash_keyState.keys();
while(i.hasMoreElements())
{
Integer key = (Integer)i.nextElement();
Integer value = (Integer)hash_keyState.get(key);
if (value.intValue() == -1) hash_keyState.remove(key);
else hash_keyState.put(key, new Integer(value.intValue()+1));
}
if (state_anyKey != 0) state_anyKey++;
if (state_keyphase == 0) state_keyphase = Sagiri.KEY_NONE;
if (state_keyphase != 0 && state_keyphase != Sagiri.KEY_NONE) state_keyphase++;
state_touchState = Sagiri.TOUCH_NONE;
}
public final void HandleKeyDown(int keycode)
{
Integer key = new Integer(keycode);
Integer value = (Integer)hash_keyState.get(key);
if (value != null)
hash_keyState.put(key, new Integer(Math.max(value.intValue(), 1)));
else
hash_keyState.put(key, new Integer(1));
state_anyKey = Math.max(state_anyKey, 1);
state_lastKey = keycode;
state_keyphase = Math.max(state_keyphase, 1);
state_keycode = keycode;
}
public final void HandleKeyUp(int keycode)
{
Integer key = new Integer(keycode);
hash_keyState.put(key, new Integer(-1));
state_anyKey = -1;
state_lastKey = keycode;
state_keyphase = -1;
state_keycode = keycode;
}
public final void HandleTouch(int phase, int x, int y)
@ -66,13 +36,7 @@ public final class Input {
public final boolean IsKeyHeld(int keycode)
{
Integer key = new Integer(keycode);
Integer value = (Integer)hash_keyState.get(key);
if (value != null)
return value.intValue() > 0;
else
return false;
return (state_keycode == keycode) && (state_keyphase > 0);
}
public final boolean IsKeyHeld(int[] keycode)
@ -84,13 +48,7 @@ public final class Input {
public final boolean IsKeyDown(int keycode)
{
Integer key = new Integer(keycode);
Integer value = (Integer)hash_keyState.get(key);
if (value != null)
return value.intValue() == 0;
else
return false;
return (state_keycode == keycode) && (state_keyphase == 0);
}
public final boolean IsKeyDown(int[] keycode)
@ -102,13 +60,7 @@ public final class Input {
public final boolean IsKeyReleased(int keycode)
{
Integer key = new Integer(keycode);
Integer value = (Integer)hash_keyState.get(key);
if (value != null)
return value.intValue() == -1;
else
return false;
return (state_keycode == keycode) && (state_keyphase == -1);
}
public final boolean IsKeyReleased(int[] keycode)
@ -118,9 +70,7 @@ public final class Input {
return false;
}
public final boolean IsKeyHeldAny() { return state_anyKey > 1; }
public final boolean IsKeyDownAny() { return state_anyKey == 1; }
public final boolean IsKeyReleasedAny() { return state_anyKey == -1; }
public final Integer getKeyStatus(int keycode) { return (Integer)hash_keyState.get(new Integer(keycode)); }
public final boolean IsKeyHeldAny() { return state_keyphase > 1; }
public final boolean IsKeyDownAny() { return state_keyphase == 1; }
public final boolean IsKeyReleasedAny() { return state_keyphase == -1; }
}

View File

@ -4,6 +4,32 @@ import javax.microedition.lcdui.Graphics;
public class Sagiri
{
public static final int KEY_NONE = -3422;
public static final int KEY_UP = -1;
public static final int KEY_DOWN = -2;
public static final int KEY_LEFT = -3;
public static final int KEY_RIGHT = -4;
public static final int KEY_0 = 48;
public static final int KEY_1 = 49;
public static final int KEY_2 = 50;
public static final int KEY_3 = 51;
public static final int KEY_4 = 52;
public static final int KEY_5 = 53;
public static final int KEY_6 = 54;
public static final int KEY_7 = 55;
public static final int KEY_8 = 56;
public static final int KEY_9 = 57;
public static final int KEY_STAR = 42;
public static final int KEY_POUND = 35;
public static final int KEY_CENTER = -5;
public static final int[] KEY_LEFT_SOFT = { -6, -202, -21, 21, -11, 105, -20};
public static final int[] KEY_RIGHT_SOFT = {-7, -203, -22, 22, 106, -21};
public final static int TOUCH_NONE = 0;
public final static int TOUCH_BEGIN = 1;
public final static int TOUCH_END = 2;
@ -38,8 +64,6 @@ public class Sagiri
_scene_current.Update(time_delta, g);
}
input.Update();
}
public Scene Get_Scene() { return _scene_current; }

View File

@ -5,6 +5,7 @@ import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
import sillysagiri.BMF;
import sillysagiri.Easing;
import sillysagiri.Scene;
import sillysagiri.Utils;
@ -13,30 +14,34 @@ public class Intro extends Scene {
private long counter = 0;
private int state = 0;
private BMF bmf_normal;
private BMF bmf_black;
private BMF bmf_outline;
private Image img_logo = null;
private Image img_ez = null;
private Image img_theworld = null;
private Image img_vol1 = null;
private Image img_project = null;
public Intro() throws IOException
{
super();
img_logo = Image.createImage("/t_1.png");
img_ez = Image.createImage("/pEZ.png");
}
public void Preload() {
try
{
bmf_normal = BMF.Create("/silly/bmf/nds12_0.png", "/silly/bmf/nds12.fnt");
bmf_outline = BMF.Create("/silly/bmf/onds12_0.png", "/silly/bmf/onds12.fnt");
bmf_black = BMF.Create("/silly/bmf/nds12_0.png", "/silly/bmf/nds12.fnt");
bmf_black.SetColor(0xFFFF0000);
img_logo = Image.createImage("/t_1.png");
}
catch(Exception e)
{
sagiri.Set_Scene(new DeathError(e));
}
}
public void Destroy()
{
img_logo = null;
img_ez = null;
img_theworld = null;
img_vol1 = null;
img_project = null;
bmf_normal = null;
bmf_black = null;
bmf_outline = null;
}
public void Update(long dt, Graphics g)
@ -84,10 +89,11 @@ public class Intro extends Scene {
try {
img_logo = Image.createImage("/t_0.png");
img_theworld = Image.createImage("/t_2.png");
img_project = Image.createImage("/t_3.png");
img_vol1 = Image.createImage("/t_4.png");
}
catch(IOException e) {}
catch(IOException e)
{
sagiri.Set_Scene(new DeathError(e));
}
}
}
break;
@ -105,20 +111,27 @@ public class Intro extends Scene {
Utils.GetScreenWidth()/2, Utils.GetScreenHeight()/2,
Graphics.HCENTER | Graphics.TOP);
g.drawImage(img_project, 5, Utils.GetScreenHeight()-5, Graphics.LEFT | Graphics.BOTTOM);
g.drawImage(img_vol1, 5, 5, Graphics.LEFT | Graphics.TOP);
// TODO: fix utf-16 symbol
bmf_black.DrawEx(g,
"c Project .hack",
5, Utils.GetScreenHeight()-5,
Graphics.LEFT | Graphics.BOTTOM);
bmf_normal.Draw(g,
"VOL 1 - v0.1-silly",
5, 5);
if (counter >= 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);
g.drawImage(bmf_black.img, 0, 0, 20);
if (sagiri.input.IsKeyDownAny())
{
sagiri.Set_Scene(new MainMenu());
}
}
break;

View File

@ -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;