📄 agesbase.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
import com.nokia.mid.ui.FullCanvas;
import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreNotFoundException;
abstract class AgesBase extends MIDlet
implements Runnable
{
public class Puyo2Canvas extends FullCanvas
{
private int key_buf;
private int key_pressed;
public int getKeyState()
{
int i = key_buf | key_pressed;
key_pressed = 0;
return i;
}
public synchronized void keyPressed(int i)
{
if(i == 48)
key_buf = bitOn(key_buf, 0);
else
if(i == 49)
key_buf = bitOn(key_buf, 1);
else
if(i == 50)
key_buf = bitOn(key_buf, 2);
else
if(i == 52)
key_buf = bitOn(key_buf, 4);
else
if(i == 53)
key_buf = bitOn(key_buf, 5);
else
if(i == 54)
key_buf = bitOn(key_buf, 6);
else
if(i == 56)
key_buf = bitOn(key_buf, 8);
else
if(i == 35)
key_buf = bitOn(key_buf, 11);
else
if(i == 42)
key_buf = bitOn(key_buf, 10);
else
if(i == -1)
key_buf = bitOn(key_buf, 12);
else
if(i == -2)
key_buf = bitOn(key_buf, 15);
else
if(i == -3)
key_buf = bitOn(key_buf, 13);
else
if(i == -4)
key_buf = bitOn(key_buf, 14);
else
if(i == -5)
key_buf = bitOn(key_buf, 16);
else
if(i == -6)
key_buf = bitOn(key_buf, 17);
else
if(i == -7)
key_buf = bitOn(key_buf, 18);
}
public synchronized void keyReleased(int i)
{
if(i == 48)
key_buf = bitOff(key_buf, 0);
else
if(i == 49)
key_buf = bitOff(key_buf, 1);
else
if(i == 50)
key_buf = bitOff(key_buf, 2);
else
if(i == 52)
key_buf = bitOff(key_buf, 4);
else
if(i == 53)
key_buf = bitOff(key_buf, 5);
else
if(i == 54)
key_buf = bitOff(key_buf, 6);
else
if(i == 56)
key_buf = bitOff(key_buf, 8);
else
if(i == 35)
key_buf = bitOff(key_buf, 11);
else
if(i == 42)
key_buf = bitOff(key_buf, 10);
else
if(i == -1)
key_buf = bitOff(key_buf, 12);
else
if(i == -2)
key_buf = bitOff(key_buf, 15);
else
if(i == -3)
key_buf = bitOff(key_buf, 13);
else
if(i == -4)
key_buf = bitOff(key_buf, 14);
else
if(i == -5)
key_buf = bitOff(key_buf, 16);
else
if(i == -6)
key_buf = bitOff(key_buf, 17);
else
if(i == -7)
key_buf = bitOff(key_buf, 18);
}
public int bitOn(int i, int j)
{
i = bitOff(i, j);
i |= 1 << j;
key_pressed = i;
return i;
}
public int bitOff(int i, int j)
{
i &= ~(1 << j);
return i;
}
public void paint(Graphics g)
{
AgesBase.gc = g;
if(paint_flag)
{
g.setColor(0);
g.fillRect(0, 0, getWidth(), getHeight());
}
AgesBase.keyData = getKeyState();
AgesBase.keyPush = AgesBase.keyData & ~AgesBase.keyLast;
AgesBase.keyRepeat = AgesBase.keyPush;
if(AgesBase.keyPush != 0)
AgesBase.keyCounter = 8;
else
if(--AgesBase.keyCounter == 0)
{
AgesBase.keyRepeat = AgesBase.keyData;
AgesBase.keyCounter = 2;
}
AgesBase.keyLast = AgesBase.keyData;
AgesBase.commonCounter++;
boolean flag = paint_flag;
paint_flag = false;
g.setClip(AgesBase.offsetX, AgesBase.offsetY, 150, 170);
game_synch(flag);
}
protected synchronized void hideNotify()
{
paint_flag = true;
key_buf = 0;
AgesBase.stopBgm();
AgesBase.once = false;
if(AgesBase.game_mode == 4)
AgesBase.key_pause = true;
else
if(AgesBase.game_mode == 2)
AgesBase.game_mode = 3;
}
protected synchronized void showNotify()
{
paint_flag = true;
key_buf = 0;
}
Puyo2Canvas()
{
key_buf = 0;
key_pressed = 0;
AgesBase.offsetX = (getWidth() - 150) / 2;
AgesBase.offsetY = (getHeight() - 170) / 2;
}
}
private static Display display;
public static int game_mode;
public static MIDlet midlet;
public static Puyo2Canvas canvas;
protected static Thread thread = null;
public static Class _class;
private static Random random = null;
static int keyData = 0;
static int keyPush = 0;
static int keyRepeat = 0;
static int keyCounter = 0;
static int keyLast = 0;
public static int offsetX;
public static int offsetY;
public static boolean stopflag;
public static boolean once;
public Image logo;
public static Graphics gc = null;
public static int commonCounter = 0;
private static InputStream _is = null;
private static boolean load_flag;
public static boolean draw_flag = true;
public static boolean sound_flag;
private boolean paint_flag;
static final int KEY_REPEAT1 = 8;
static final int KEY_REPEAT2 = 2;
// public static final Player sound[] = new Player[2];
public static boolean key_pause = false;
public AgesBase()
{
paint_flag = true;
midlet = this;
_class = getClass();
canvas = new Puyo2Canvas();
display = Display.getDisplay(this);
try
{
logo = Image.createImage("/segalogo.png");
}
catch(IOException ioexception) { }
random = new Random(System.currentTimeMillis());
}
static void playBgm(int i)
{
// try
// {
// stopBgm();
// if(sound_flag && sound[i].getState() != 400)
// {
// sound[i].realize();
// sound[i].setMediaTime(0L);
// sound[i].setLoopCount(-1);
// sound[i].prefetch();
// sound[i].start();
// }
// }
// catch(MediaException mediaexception) { }
}
static void stopBgm()
{
// try
// {
// for(int i = 0; i < 2; i++)
// if(sound[i] != null && sound[i].getState() == 400)
// sound[i].stop();
//
// }
// catch(MediaException mediaexception)
// {
// System.out.println("Error in stopping media");
// }
}
static void pauseBgm()
{
// try
// {
// sound[1].stop();
// }
// catch(MediaException mediaexception)
// {
// System.out.println("Error in mediaexception");
// }
}
static void resumeBgm()
{
stopBgm();
// try
// {
// if(sound_flag && sound[1].getState() != 400)
// {
// sound[1].realize();
// sound[1].setMediaTime(0L);
// sound[1].setLoopCount(-1);
// sound[1].prefetch();
// sound[1].start();
// }
// }
// catch(MediaException mediaexception) { }
}
abstract void game_synch(boolean flag);
public void startApp()
{
if(thread == null)
{
display.setCurrent(canvas);
thread = new Thread(this);
thread.start();
}
}
public void pauseApp()
{
}
public void destroyApp(boolean flag)
{
stopBgm();
}
public void run()
{
do
{
if(thread == null)
break;
try
{
long l = System.currentTimeMillis();
canvas.repaint();
long l1 = System.currentTimeMillis() - l;
if(l1 < 30L)
Thread.sleep(30L - l1);
}
catch(Exception exception) { }
} while(true);
}
public static int rnd(int i)
{
return (random.nextInt() & 0x7fffffff) % i;
}
public static void drawString(int i, String s, int j, int k, int l)
{
gc.setColor(0x404040);
gc.drawString(s, (offsetX + j) - 1, offsetY + k, l);
gc.drawString(s, j + 1 + offsetX, offsetY + k, l);
gc.drawString(s, j + offsetX, (offsetY + k) - 1, l);
gc.drawString(s, j + offsetX, offsetY + k + 1, l);
gc.setColor(i);
gc.drawString(s, j + offsetX, offsetY + k, l);
}
public static void drawString(int i, String s, int j, int k)
{
drawString(i, s, j, k, 20);
}
public static void drawCenter(int i, String s, int j)
{
drawString(i, s, 75, j, 17);
}
public static void file_open(int i)
{
load_flag = true;
do
try
{
if(_is != null)
_is.close();
_is = _class.getResourceAsStream("f" + i);
return;
}
catch(Exception exception)
{
Thread.yield();
}
while(true);
}
public static boolean file_close()
{
try{
if (_is == null)
return true;
_is.close();
_is = null;
return true;
}catch(Exception e){}
return false;
}
public static byte[] load_resource()
{
try{
if (!load_flag)
return null;
Thread.yield();
byte abyte0[];
int i = _is.read();
i += _is.read() << 8;
abyte0 = new byte[i];
_is.read(abyte0);
return abyte0;
}catch(Exception e){}
load_flag = false;
return null;
}
public static boolean skip_resource(int i)
{
do
{
if(i <= 0)
break;
try
{
int j = _is.read();
j += _is.read() << 8;
_is.skip(j);
i--;
}
catch(Exception exception)
{
load_flag = false;
return false;
}
} while(true);
return true;
}
public static Image load_image()
{
try{
byte abyte0[] = load_resource();
return Image.createImage(abyte0, 0, abyte0.length);
}catch(Exception e){}
load_flag = false;
return null;
}
public static byte[] readSram(String s)
{
try{
byte abyte0[];
RecordStore recordstore = RecordStore.openRecordStore(s, false);
abyte0 = recordstore.getRecord(1);
recordstore.closeRecordStore();
return abyte0;
}catch(Exception e){}
return null;
}
public static void writeSram(String s, byte abyte0[], boolean flag)
{
do
try
{
RecordStore recordstore = RecordStore.openRecordStore(s, true);
if(flag)
recordstore.addRecord(abyte0, 0, abyte0.length);
else
recordstore.setRecord(1, abyte0, 0, abyte0.length);
recordstore.closeRecordStore();
return;
}
catch(Exception exception) { }
while(true);
}
public static final void sleep(long l)
{
System.gc();
try
{
Thread.sleep(l);
}
catch(Exception exception) { }
}
public static void sleep()
{
try
{
System.gc();
Thread.sleep(30L);
}
catch(Exception exception) { }
}
public static final void drawArrow(int i, int j)
{
int k = j + 7;
gc.setColor(0xffffff);
for(int l = 3; l >= 0; l--)
{
gc.drawLine(i, j, (i + 7) - l * 2, j);
gc.drawLine(i, k, (i + 7) - l * 2, k);
j++;
k--;
}
}
public static final int getInteger(byte abyte0[], int i)
{
return ((abyte0[i] & 0xff) << 24) + ((abyte0[i + 1] & 0xff) << 16) + ((abyte0[i + 2] & 0xff) << 8) + (abyte0[i + 3] & 0xff);
}
public static final void setInteger(byte abyte0[], int i, int j)
{
abyte0[i] = (byte)(j >> 24);
abyte0[i + 1] = (byte)(j >> 16);
abyte0[i + 2] = (byte)(j >> 8);
abyte0[i + 3] = (byte)j;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -