- 积分
- 14
- 实力分
- 点
- 金钱数
- 两
- 技术分
- 分
- 贡献分
- 分
|

楼主 |
发表于 2005-8-15 00:22:00
|
显示全部楼层
// 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
// Source File Name: GPSRec.java
import com.siemens.mp.game.ExtendedImage;
import com.siemens.mp.io.File;
import java.io.IOException;
import java.io.PrintStream;
import javax.microedition.lcdui.*;
class GPSRec extends Canvas
implements Runnable
{
private GPS6688 gps6688;
private Thread thread;
private Image bkbuffer;
private ExtendedImage ei;
private int ox;
private int oy;
private int mx;
private int my;
private int biWidth;
private int biHeight;
private int direct;
private boolean running;
private boolean readytopaint;
private boolean getinfo;
private boolean showinfo;
private boolean loading;
private File file;
private int fn;
private byte rgbq[];
private byte bh[];
private int nb;
private int bpl;
private byte bw[];
private String strAreaID;
private String strCellID;
private String strSignal;
public GPSRec(GPS6688 gps6688_1, MainWindow mainwindow)
{
bkbuffer = Image.createImage(112, 80);
ei = new ExtendedImage(bkbuffer);
ox = 0;
oy = 0;
mx = 1736;
my = 1160;
biWidth = 0;
biHeight = 0;
direct = 0;
running = true;
readytopaint = false;
getinfo = true;
showinfo = true;
loading = false;
file = new File();
fn = 0;
rgbq = new byte[8];
bh = new byte[54];
nb = 0;
bpl = 0;
bw = new byte[1120];
strAreaID = "0000";
strCellID = "0000";
strSignal = "+00";
gps6688 = gps6688_1;
try
{
fn = file.open(gps6688_1.mapFiles[gps6688_1.mapidx] + ".bmp");
file.read(fn, bh, 0, 54);
file.read(fn, rgbq, 0, 8);
biWidth = (bh[18] >= 0 ? bh[18] : 256 + bh[18]) + ((bh[19] >= 0 ? bh[19] : 256 + bh[19]) << 8);
biHeight = (bh[22] >= 0 ? bh[22] : 256 + bh[22]) + ((bh[23] >= 0 ? bh[23] : 256 + bh[23]) << 8);
mx = biWidth >> 1;
my = biHeight >> 1;
nb = biWidth % 8 != 0 ? biWidth / 8 + 1 : biWidth / 8;
bpl = nb + (nb % 4 != 0 ? 4 - nb % 4 : 0);
}
catch(Exception exception)
{
running = false;
}
GetInfo();
LoadMap(mx, my);
thread = new Thread(this);
thread.start();
readytopaint = true;
repaint();
}
public void unloadGPSRec()
{
running = false;
}
protected void keyPressed(int i)
{
if(!readytopaint)
return;
while(loading) ;
switch(getGameAction(i))
{
case 1: // '\001'
direct = 1;
break;
case 6: // '\006'
direct = 2;
break;
case 2: // '\002'
direct = 3;
break;
case 5: // '\005'
direct = 4;
break;
}
switch(i)
{
case 50: // '2'
direct = 5;
break;
case 56: // '8'
direct = 6;
break;
case 52: // '4'
direct = 7;
break;
case 54: // '6'
direct = 8;
break;
case 53: // '5'
showinfo = !showinfo;
direct = 9;
break;
case 48: // '0'
getinfo = !getinfo;
break;
}
}
protected void keyRepeated(int i)
{
keyPressed(i);
}
protected void keyReleased(int i)
{
direct = 0;
}
public void paint(Graphics g)
{
if(!readytopaint)
return;
ei.setPixels(bw, 0, 0, 112, 80);
Graphics g1 = bkbuffer.getGraphics();
for(int i = 44; i <= 48; i++)
ei.setPixel(i, 40, (byte)(ei.getPixel(i, 40) != 0 ? 0 : 1));
for(int j = 52; j <= 56; j++)
ei.setPixel(j, 40, (byte)(ei.getPixel(j, 40) != 0 ? 0 : 1));
for(int k = 34; k <= 38; k++)
ei.setPixel(50, k, (byte)(ei.getPixel(50, k) != 0 ? 0 : 1));
for(int l = 42; l <= 46; l++)
ei.setPixel(50, l, (byte)(ei.getPixel(50, l) != 0 ? 0 : 1));
if(showinfo)
{
g1.setColor(255, 255, 255);
g1.fillRect(5, 66, 90, 12);
g1.setColor(0, 0, 0);
g1.drawRect(5, 66, 90, 12);
Font font = Font.getFont(0, 0, 8);
g1.setFont(font);
g1.drawString(strAreaID + " " + strCellID + " " + strSignal + " " + (getinfo ? "V" : "X"), 7, 68, 20);
}
g.drawImage(bkbuffer, 0, 0, 20);
}
private void MapView(int i, int j)
{
while(loading) ;
loading = true;
if(ox != i && oy != j)
LoadMap(i, j);
else
if(ox != i)
LoadMapX(i, j);
else
if(oy != j)
LoadMapY(i, j);
loading = false;
}
private void LoadMapX(int i, int j)
{
int k = 0;
int l = 0;
if(i > ox)
try
{
byte abyte0[] = new byte[bpl * 40];
k = file.seek(fn, 62 + (biHeight - (j + 79)) * bpl + (ox + 112) / 8);
for(int i1 = j + 79; i1 >= j; i1 -= 40)
{
for(int k1 = 0; k1 < 40; k1++)
System.arraycopy(bw, (i1 - k1 - j) * 14 + (i - ox) / 8, bw, (i1 - k1 - j) * 14, 14 - (i - ox) / 8);
l = file.read(fn, abyte0, 0, abyte0.length);
if(bh[46] == gps6688.mapbk)
{
for(int i2 = 0; i2 < abyte0.length; i2 += bpl)
{
for(int i3 = i2; i3 < i2 + (i - ox) / 8; i3++)
abyte0[i3] = (byte)(~abyte0[i3]);
}
}
for(int j2 = 0; j2 < 40; j2++)
System.arraycopy(abyte0, j2 * bpl, bw, ((i1 - j2 - j) * 14 + 14) - (i - ox) / 8, (i - ox) / 8);
}
abyte0 = null;
}
catch(IOException ioexception)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("IOException: " + ioexception.getMessage());
System.out.println("r1=" + k + " r2=" + l);
}
else
try
{
byte abyte1[] = new byte[bpl * 40];
k = file.seek(fn, 62 + (biHeight - (j + 79)) * bpl + i / 8);
for(int j1 = j + 79; j1 >= j; j1 -= 40)
{
for(int l1 = 0; l1 < 40; l1++)
System.arraycopy(bw, (j1 - l1 - j) * 14, bw, (j1 - l1 - j) * 14 + (ox - i) / 8, 14 - (ox - i) / 8);
l = file.read(fn, abyte1, 0, abyte1.length);
if(bh[46] == gps6688.mapbk)
{
for(int k2 = 0; k2 < abyte1.length; k2 += bpl)
{
for(int j3 = k2; j3 < k2 + (ox - i) / 8; j3++)
abyte1[j3] = (byte)(~abyte1[j3]);
}
}
for(int l2 = 0; l2 < 40; l2++)
System.arraycopy(abyte1, l2 * bpl, bw, (j1 - l2 - j) * 14, (ox - i) / 8);
}
abyte1 = null;
}
catch(IOException ioexception1)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("IOException: " + ioexception1.getMessage());
System.out.println("r1=" + k + " r2=" + l);
}
}
private void LoadMapY(int i, int j)
{
int k = 0;
int l = 0;
if(j > oy)
{
if(j - oy == 8)
try
{
byte abyte0[] = new byte[bpl * 8];
System.arraycopy(bw, (j - oy) * 14, bw, 0, 14 * (80 - (j - oy)));
k = file.seek(fn, 62 + (biHeight - (j + 79)) * bpl + i / 8);
for(int i1 = j + 79; i1 > (j + 79) - (j - oy); i1 -= 8)
{
l = file.read(fn, abyte0, 0, abyte0.length);
if(bh[46] == gps6688.mapbk)
{
for(int i2 = 0; i2 < abyte0.length; i2 += bpl)
{
for(int k3 = i2; k3 < i2 + 14; k3++)
abyte0[k3] = (byte)(~abyte0[k3]);
}
}
for(int j2 = 0; j2 < 8; j2++)
System.arraycopy(abyte0, j2 * bpl, bw, (i1 - j2 - j) * 14, 14);
}
abyte0 = null;
}
catch(IOException ioexception)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("IOException: " + ioexception.getMessage());
System.out.println("r1=" + k + " r2=" + l);
}
else
try
{
byte abyte1[] = new byte[bpl];
System.arraycopy(bw, (j - oy) * 14, bw, 0, 14 * (80 - (j - oy)));
k = file.seek(fn, 62 + (biHeight - (j + 79)) * bpl + i / 8);
for(int j1 = j + 79; j1 > (j + 79) - (j - oy); j1--)
{
l = file.read(fn, abyte1, 0, abyte1.length);
if(bh[46] == gps6688.mapbk)
{
for(int k2 = 0; k2 < abyte1.length; k2++)
abyte1[k2] = (byte)(~abyte1[k2]);
}
System.arraycopy(abyte1, 0, bw, (j1 - j) * 14, 14);
}
abyte1 = null;
}
catch(IOException ioexception1)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("IOException: " + ioexception1.getMessage());
System.out.println("r1=" + k + " r2=" + l);
}
} else
if(oy - j == 8)
try
{
byte abyte2[] = new byte[bpl * 8];
System.arraycopy(bw, 0, bw, (oy - j) * 14, 14 * (80 - (oy - j)));
k = file.seek(fn, 62 + (biHeight - (oy - 1)) * bpl + i / 8);
for(int k1 = oy - 1; k1 >= j; k1 -= 8)
{
l = file.read(fn, abyte2, 0, abyte2.length);
if(bh[46] == gps6688.mapbk)
{
for(int l2 = 0; l2 < abyte2.length; l2 += bpl)
{
for(int l3 = l2; l3 < l2 + 14; l3++)
abyte2[l3] = (byte)(~abyte2[l3]);
}
}
for(int i3 = 0; i3 < 8; i3++)
System.arraycopy(abyte2, i3 * bpl, bw, (k1 - i3 - j) * 14, 14);
}
abyte2 = null;
}
catch(IOException ioexception2)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("IOException: " + ioexception2.getMessage());
System.out.println("r1=" + k + " r2=" + l);
}
else
try
{
byte abyte3[] = new byte[bpl];
System.arraycopy(bw, 0, bw, (oy - j) * 14, 14 * (80 - (oy - j)));
k = file.seek(fn, 62 + (biHeight - (oy - 1)) * bpl + i / 8);
for(int l1 = oy - 1; l1 >= j; l1--)
{
l = file.read(fn, abyte3, 0, abyte3.length);
if(bh[46] == gps6688.mapbk)
{
for(int j3 = 0; j3 < abyte3.length; j3++)
abyte3[j3] = (byte)(~abyte3[j3]);
}
System.arraycopy(abyte3, 0, bw, (l1 - j) * 14, 14);
}
abyte3 = null;
}
catch(IOException ioexception3)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("IOException: " + ioexception3.getMessage());
System.out.println("r1=" + k + " r2=" + l);
}
}
private void LoadMap(int i, int j)
{
int k = 0;
int l = 0;
try
{
byte abyte0[] = new byte[bpl * 40];
k = file.seek(fn, 62 + (biHeight - (j + 79)) * bpl + i / 8);
for(int i1 = j + 79; i1 >= j; i1 -= 40)
{
l = file.read(fn, abyte0, 0, abyte0.length);
if(bh[46] == gps6688.mapbk)
{
for(int j1 = 0; j1 < abyte0.length; j1 += bpl)
{
for(int l1 = j1; l1 < j1 + 14; l1++)
abyte0[l1] = (byte)(~abyte0[l1]);
}
}
for(int k1 = 0; k1 < 40; k1++)
System.arraycopy(abyte0, k1 * bpl, bw, (i1 - k1 - j) * 14, 14);
}
abyte0 = null;
}
catch(IOException ioexception)
{
gps6688.showAlert("r1=" + k + " r2=" + l);
System.out.println("r1=" + k + " r2=" + l);
}
}
public void recordInfo()
{
while(loading) ;
int i = mx + 50;
int j = my + 40;
String s = "";
String s1 = "";
if(i < 1000)
s = "0";
if(i < 100)
s = "00";
if(i < 10)
s = "000";
s = s + i;
if(j < 1000)
s1 = "0";
if(j < 100)
s1 = "00";
if(j < 10)
s1 = "000";
s1 = s1 + j;
String s2 = "";
if(gps6688.mapidx < 1000)
s2 = "0";
if(gps6688.mapidx < 100)
s2 = "00";
if(gps6688.mapidx < 10)
s2 = "000";
s2 = s2 + gps6688.mapidx;
byte abyte0[] = new byte[2];
abyte0[0] = 13;
abyte0[1] = 10;
String s3 = new String(abyte0);
int k = -1;
try
{
File file1 = new File();
File _tmp = file1;
if(File.exists("areas.ini") >= 0)
{
int l = file1.open("areas.ini");
if(file1.length(l) >= 11)
{
byte abyte1[] = new byte[11];
for(int j1 = 0; j1 < file1.length(l) / 11; j1++)
{
file1.read(l, abyte1, 0, 11);
String s6 = new String(abyte1);
if(!s6.equals(s2 + "," + strAreaID + s3))
continue;
k = j1 * 11;
break;
}
}
if(k >= 0)
{
String s4 = s2 + "," + strAreaID + s3;
file1.seek(l, k);
file1.write(l, s4.getBytes(), 0, 11);
file1.close(l);
} else
{
file1.close(l);
File _tmp1 = file1;
File.debugWrite("areas.ini", s2 + "," + strAreaID + s3);
}
} else
{
File _tmp2 = file1;
File.debugWrite("areas.ini", s2 + "," + strAreaID + s3);
}
file1 = null;
}
catch(Exception exception)
{
System.out.println("Exception :" + exception);
}
k = -1;
try
{
File file2 = new File();
File _tmp3 = file2;
if(File.exists(strAreaID + ".txt") >= 0)
{
int i1 = file2.open(strAreaID + ".txt");
if(file2.length(i1) >= 16)
{
byte abyte2[] = new byte[16];
for(int k1 = 0; k1 < file2.length(i1) / 16; k1++)
{
file2.read(i1, abyte2, 0, 16);
String s7 = new String(abyte2);
if(!s7.substring(0, 4).equals(strCellID))
continue;
k = k1 * 16;
break;
}
}
if(k >= 0)
{
String s5 = strCellID + "," + s + "," + s1 + s3;
file2.seek(i1, k);
file2.write(i1, s5.getBytes(), 0, 16);
file2.close(i1);
} else
{
file2.close(i1);
File _tmp4 = file2;
File.debugWrite(strAreaID + ".txt", strCellID + "," + s + "," + s1 + s3);
}
} else
{
File _tmp5 = file2;
File.debugWrite(strAreaID + ".txt", strCellID + "," + s + "," + s1 + s3);
}
file2 = null;
}
catch(Exception exception1)
{
System.out.println("Exception :" + exception1);
}
}
public void run()
{
long l = System.currentTimeMillis();
while(running)
try
{
Thread.yield();
if(getinfo && System.currentTimeMillis() - l >= (long)(gps6688.timeSetting * 1000))
{
GetInfo();
repaint();
l = System.currentTimeMillis();
}
Thread.yield();
if(direct != 0)
{
switch(direct)
{
default:
break;
case 1: // '\001'
my -= 8;
if(my < 0)
my = 0;
break;
case 2: // '\002'
my += 8;
if(my > biHeight - 80)
my = biHeight - 80;
break;
case 3: // '\003'
mx -= 8;
if(mx < 0)
mx = 0;
break;
case 4: // '\004'
mx += 8;
if(mx > biWidth - 100)
mx = biWidth - 100;
break;
case 5: // '\005'
my -= 70;
if(my < 0)
my = 0;
break;
case 6: // '\006'
my += 70;
if(my > biHeight - 80)
my = biHeight - 80;
break;
case 7: // '\007'
mx -= 88;
if(mx < 0)
mx = 0;
break;
case 8: // '\b'
mx += 88;
if(mx > biWidth - 100)
mx = biWidth - 100;
break;
}
MapView(mx, my);
repaint();
ox = mx;
oy = my;
}
}
catch(Exception exception) { }
try
{
file.close(fn);
}
catch(Exception exception1) { }
bkbuffer = null;
ei = null;
thread = null;
}
public void GetInfo()
{
int i;
while(loading) ;
i = 0;
strAreaID = IntToHex2(peekb(0x39d84)) + IntToHex2(peekb(0x39d85));
strCellID = IntToHex2(peekb(0x39d87)) + IntToHex2(peekb(0x39d86));
i = peekb(0x39d8f);
if(i > 127)
{
i |= 0xffffff00;
strSignal = "";
} else
{
strSignal = "+";
}
new StringBuffer();
this;
JVM INSTR dup_x1 ;
strSignal;
append();
i;
append();
toString();
strSignal;
}
public String IntToHex2(int i)
{
if(i < 0)
return "00";
if(i < 16)
return "0" + Integer.toHexString(i);
if(i < 256)
return Integer.toHexString(i);
else
return "FF";
}
private static String AddrToHex(int i)
{
String s;
for(s = Integer.toHexString(i); s.length() < 6; s = "0" + s);
return s;
}
private static int peekb(int i)
{
return Integer.valueOf(System.getProperty("X.d" + AddrToHex(i)).substring(6, 8), 16).intValue();
Exception exception;
exception;
return 0;
}
} |
|