⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 harry.java

📁 韩国人手机上的J2ME手机游戏哈里波特源代码
💻 JAVA
字号:
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2008-3-11 13:03:47
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Download by http://www.codefans.net
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.*;
import media.BackLight;

public class Harry extends MIDlet
{

    public Harry()
    {
        reclen = 38;
        display = Display.getDisplay(this);
        if(Runtime.getRuntime().totalMemory() < 0x445c0L)
            cat2 = true;
        initScore();
        if(open());
        canvas = new GameCanvas(this);
        SW = canvas.getWidth();
        SH = canvas.getHeight();
        CX = SW / 2;
        CY = SH / 2;
    }

    public void startApp()
    {
        BackLight.on(0);
        canvas.init();
    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean flag)
    {
        display.setCurrent(null);
        close();
    }

    public void initScore()
    {
        store = null;
        optionId = 0;
        optionRec = new byte[17];
        optionRec[0] = 1;
        putInt(optionRec, 1, 1);
        putInt(optionRec, 5, 1);
        putInt(optionRec, 9, 4);
        putInt(optionRec, 13, cat2 ? 0 : 1);
        scoreId = 0;
        scoreRec = new byte[5];
        scoreRec[0] = 2;
        putInt(scoreRec, 1, 0);
        slotId = 0;
        slotRec = new byte[115];
        slotRec[0] = 3;
        slotRec[1] = slotRec[2] = -1;
        slotRec[1 + reclen] = slotRec[2 + reclen] = -1;
        slotRec[1 + reclen * 2] = slotRec[2 + reclen * 2] = -1;
    }

    boolean open()
    {
        try
        {
            store = RecordStore.openRecordStore("harrydat", true);
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
        }
        if(store == null)
        {
            return false;
        } else
        {
            openOption();
            openHighscore();
            openSaveslot();
            return true;
        }
    }

    private boolean openOption()
    {
        try
        {
            optionId = 0;
            RecordEnumeration recordenumeration = store.enumerateRecords(null, null, false);
            while(recordenumeration.hasNextElement()) 
            {
                int i = recordenumeration.nextRecordId();
                if(store.getRecordSize(i) != 17)
                    continue;
                int j = store.getRecord(i, optionRec, 0);
                if(j != 17 || optionRec[0] != 1)
                    continue;
                optionId = i;
                break;
            }
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
            return false;
        }
        return true;
    }

    int getSoundOption()
    {
        return getInt(optionRec, 1);
    }

    int getEffectOption()
    {
        return getInt(optionRec, 5);
    }

    int getSpeed()
    {
        return getInt(optionRec, 9);
    }

    int getBg()
    {
        return getInt(optionRec, 13);
    }

    boolean setOption(int i, int j, int k, int l)
    {
        putInt(optionRec, 1, i);
        putInt(optionRec, 5, j);
        putInt(optionRec, 9, k);
        putInt(optionRec, 13, l);
        if(store == null)
            return false;
        try
        {
            if(optionId == 0)
                optionId = store.addRecord(optionRec, 0, optionRec.length);
            else
                store.setRecord(optionId, optionRec, 0, optionRec.length);
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
            return false;
        }
        return true;
    }

    private boolean openHighscore()
    {
        try
        {
            scoreId = 0;
            RecordEnumeration recordenumeration = store.enumerateRecords(null, null, false);
            while(recordenumeration.hasNextElement()) 
            {
                int i = recordenumeration.nextRecordId();
                if(store.getRecordSize(i) != 5)
                    continue;
                int j = store.getRecord(i, scoreRec, 0);
                if(j != 5 || scoreRec[0] != 2)
                    continue;
                scoreId = i;
                break;
            }
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
            return false;
        }
        return true;
    }

    boolean saveScore(int i)
    {
        putInt(scoreRec, 1, i);
        if(store == null)
            return false;
        try
        {
            if(scoreId == 0)
                scoreId = store.addRecord(scoreRec, 0, scoreRec.length);
            else
                store.setRecord(scoreId, scoreRec, 0, scoreRec.length);
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
            return false;
        }
        return true;
    }

    int getHighscore()
    {
        return getInt(scoreRec, 1);
    }

    private boolean openSaveslot()
    {
        try
        {
            slotId = 0;
            RecordEnumeration recordenumeration = store.enumerateRecords(null, null, false);
            while(recordenumeration.hasNextElement()) 
            {
                int i = recordenumeration.nextRecordId();
                if(store.getRecordSize(i) != 115)
                    continue;
                int j = store.getRecord(i, slotRec, 0);
                if(j != 115 || slotRec[0] != 3)
                    continue;
                slotId = i;
                break;
            }
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
            return false;
        }
        return true;
    }

    boolean saveSlot(int i, int j, int k, int l, int i1, int j1, int k1, 
            int l1, int i2, byte abyte0[], int j2, int k2)
    {
        int l2 = 1 + i * reclen;
        slotRec[l2] = (byte)j;
        slotRec[l2 + 1] = (byte)k;
        slotRec[l2 + 2] = (byte)l;
        slotRec[l2 + 3] = (byte)k2;
        slotRec[l2 + 4] = (byte)l1;
        putInt(slotRec, l2 + 8, i1);
        putInt(slotRec, l2 + 12, j1);
        putInt(slotRec, l2 + 16, k1);
        putInt(slotRec, l2 + 20, j2);
        putInt(slotRec, l2 + 24, i2);
        for(int i3 = 0; i3 < 10; i3++)
            slotRec[l2 + 28 + i3] = abyte0[i3];

        if(store == null)
            return false;
        try
        {
            if(slotId == 0)
                slotId = store.addRecord(slotRec, 0, slotRec.length);
            else
                store.setRecord(slotId, slotRec, 0, slotRec.length);
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
            return false;
        }
        return true;
    }

    int getStagenum(int i)
    {
        return slotRec[1 + i * reclen];
    }

    int getMapid(int i)
    {
        return slotRec[1 + i * reclen + 1];
    }

    int getSaveorder(int i)
    {
        return slotRec[1 + i * reclen + 2];
    }

    int getLife(int i)
    {
        return slotRec[1 + i * reclen + 3];
    }

    int getGrade(int i)
    {
        return slotRec[1 + i * reclen + 4];
    }

    int getHx(int i)
    {
        return getInt(slotRec, 1 + i * reclen + 8);
    }

    int getHy(int i)
    {
        return getInt(slotRec, 1 + i * reclen + 12);
    }

    int getExp(int i)
    {
        return getInt(slotRec, 1 + i * reclen + 16);
    }

    int getSlotscore(int i)
    {
        return getInt(slotRec, 1 + i * reclen + 20);
    }

    int getBeans(int i)
    {
        return getInt(slotRec, 1 + i * reclen + 24);
    }

    void getItems(int i, byte abyte0[])
    {
        for(int j = 0; j < 10; j++)
            abyte0[j] = slotRec[1 + i * reclen + 28 + j];

    }

    private int getInt(byte abyte0[], int i)
    {
        return (abyte0[i + 0] & 0xff) << 24 | (abyte0[i + 1] & 0xff) << 16 | (abyte0[i + 2] & 0xff) << 8 | abyte0[i + 3] & 0xff;
    }

    private void putInt(byte abyte0[], int i, int j)
    {
        abyte0[i + 0] = (byte)(j >> 24 & 0xff);
        abyte0[i + 1] = (byte)(j >> 16 & 0xff);
        abyte0[i + 2] = (byte)(j >> 8 & 0xff);
        abyte0[i + 3] = (byte)(j >> 0 & 0xff);
    }

    void close()
    {
        try
        {
            if(store != null)
                store.closeRecordStore();
        }
        catch(RecordStoreException recordstoreexception)
        {
            recordstoreexception.printStackTrace();
        }
    }

    Display display;
    GameCanvas canvas;
    static int SW = 128;
    static int SH = 149;
    static int CX = 0;
    static int CY = 0;
    static boolean cat2 = false;
    private int optionId;
    private byte optionRec[];
    private static final int OPTION_LEN = 17;
    private static final byte OPTION_TAG = 1;
    private int scoreId;
    private byte scoreRec[];
    private static final int SCORE_LEN = 5;
    private static final byte SCORE_TAG = 2;
    private int slotId;
    private byte slotRec[];
    private static final int SLOT_LEN = 115;
    private static final byte SLOT_TAG = 3;
    private RecordStore store;
    byte reclen;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -