view src/fdl/PSXReply.java @ 0:083a0b5e12cc

Apply Debug Interface version start
author fuchita
date Thu, 07 Feb 2008 14:21:30 +0900
parents
children aced4bfc15af
line wrap: on
line source


/**
 * PSXReply 
 *
 * @author Shinji Kono
 *

    psx.in(),psxrd.() return this.

    method for check answer is ready or not.

    (call back interface can be used instead of this)

    unique sequence number  */

package fdl;
import java.nio.ByteBuffer;

public class PSXReply implements PSXQueueInterface {
    public ByteBuffer command;
    public ByteBuffer data;
    public int seq;
    public PSXReply next;
    public int mode;
    public PSXCallback callback;
    static final boolean debug = false;

    public PSXReply(int _mode,PSXCallback _callback) {
	mode = _mode;
	callback = _callback;
    }

    public PSXReply() {
    }

    public void setAnswer(int _mode, ByteBuffer _command,ByteBuffer _data) {
	mode = _mode;
	data = _data;
	command = _command;
	if (debug) {
System.out.print("setAnswer mode:");
System.out.println(mode);
System.out.print("setAnswer bool:");
System.out.println(mode==PSX_ANSWER);
	}
    }

    public int getMode() {
	return command.get(LINDA_MODE_OFFSET);
    }

    public int getId() {
	return command.getShort(LINDA_ID_OFFSET);
    }

    public int getSeq() {
	return command.getInt(LINDA_SEQ_OFFSET);
    }

    public int getLength() {
	return command.getInt(LINDA_DATA_LENGTH_OFFSET);
    }

    public ByteBuffer getData() {
	data.rewind();
	return data;
    }

    public boolean ready() {
	return mode==PSX_ANSWER;
    }
}


/* end */