LIB68K SPECIFICATION

1) Members
2) Basic routines
3) Debugging routines
4) Low level access
 

1) Members

int initLib68k(void)
int closeLib68k(void)
int loadRom(const char *romname)
int doInstructions(int n)
int getCalc(void)
const char* romVersion(void)



int disasm(int addr,char *output)
int setBreakpointAddress(int address)
int setBreakpointRange(int addressMin,int addressMax,int mode)
int setBreakpointAccess(int address, int mode)
void setBreakpointVector(int id)
int setBreakpointTrap(int trap)
void getBreakpointCause(int *type,int *id,int *mode)
void delBreakpointAddress(int address)
void delBreakpointAccess(int id)
void delBreakpointAccessRange(int id)
void delBreakpointVector(int id)
void delBreakpointTrap(int id)



void setDataRegister(int n,int val)
void setAddressRegister(int n,int val)
void setSpRegister(int val)
void setPcRegister(int val)
void setSrRegister(int val)
void setFlagRegister(unsigned char flag)
int getDataRegister(int n)
int getAddressRegister(int n)
int getSpRegister(void)
int getPcRegister(void)
int getSrRegister(void)
unsigned char getFlagRegister(void)
void* getRam(void)
void* getRom(void)
void* getLcdmem(void)
char getContrast(void)
void setActiveKey(int key,int active)
 

2) Basic routines

int initLib68k(void)

This function must be called first. It allocates memory buffer and makes some initilisation.
Return : zero if initialisation is unsuccessfull otherwise non-zero.
Implementation : bugs fixed


int closeLib68k(void)

This function must be called in the end of the program.
Return : zero if unsuccessfull otherwise non-zero.
Implementation : bugs fixed


int loadRom(const char *romname)

Load a rom file, make necessary CPU initialisation and use it by default. The rom file can be one of those format : *.tib, *.rom, *.9xu.
Romname : file name in current directory or complete file path.
Return : zero if unsuccessfull otherwise non-zero.
Implementation : not really finished yet =). It works fine with ti92 rom x.x, ti92plus rom 1.x (not rom 2.x) and ti89 rom 1.0.


int doInstructions(int n)

n : number of cpu instruction.
Return : zero if a breakpoint had been called otherwise non-zero.
Implementation : bugs fixed


int getCalc(void)

Call this function to retrieve the type of the current calculator.
Return : a flag. Here are the bit mask :
    TI92
    TI89
    MODULEPLUS
Implementation : not finishd, always return TI92 | MODULEPLUS currently. TODO : find a way to retrieve the calculator type ...


const char* romVersion(void)

Return : a pointer to a string contening information about rom version.
Implementation : NOT IMPLEMENTED YET
 
 

3) Debugging routines

int disasm(int addr,char *output)

Dissasemble an instruction located at the specified address.
addr : address of the instruction.
output : address of a string for storing instruction (50 characters should be enough).
Return : size of instruction (0 if it is an illegal instruction or if address is not valid).
Implementation : not finished yet, should not work correctly with illegal instruction and invalid address.


int setBreakpointAddress(int address)

Activate a breakpoint at the specified address. Cause the end of doInstruction function when PC==address.
address : address of code breakpoint.
Return : breakpoint id : -1 means that the breakpoint could not be set.
Implementation : maybe some bugs with intlist ...


int setBreakpointRange(int addressMin,int addressMax,int mode)

Activate a breakpoint at the specified address. Cause the end of doInstruction function when PC==address.
address : address of code breakpoint.
mode : it must be one of these values :
    BK_READ
    BK_WRITE
Return : breakpoint id : -1 means that the breakpoint could not be set.
Implementation : maybe some bugs with intlist ...


int setBreakpointAccess(int address, int mode)

Activate a breakpoint when the CPU try to write or read a byte/word/long word at the specified address.
address : address of code breakpoint.
mode : it must be one of these values :
    BK_READ_BYTE
    BK_READ_WORD
    BK_READ_LONG_WORD
    BK_WRITE_BYTE
    BK_WRITE_WORD
    BK_WRITE_LONG_WORD
Return : breakpoint id : -1 means that the breakpoint could not be set.
Implementation : should works


void setBreakpointVector(int vector)

Activate a breakpoint on a CPU exception.
vector : should be one of these values :
    BK_ADDRESS_ERROR
    BK_ILLEGAL_INSTRUCTION
    BK_ZERO_DIVIDE
    BK_CHK_INSTRUCTION
    BK_TRAPV_INSTRUCTION
    BK_PRIVILEGE_VIOLATION
    BK_TRACE
    BK_LINE1010
    BK_LINE1011
Return : breakpoint id : -1 means that the breakpoint could not be set.
Implementation : NOT IMPLEMENTED YET, return -1 every time.


int setBreakpointTrap(int trap)

Activate a breakpoint at a specified trap instruction.
trap : trap number.
Return : breakpoint id : -1 means that the breakpoint could not be set.
Implementation : NOT IMPLEMENTED YET, return -1 every time.


void getBreakpointCause(int *type,int *id,int *mode)

Retrieve the cause which have interrupts doInstructions().
type : the value returned inshould be one of these values :
    BK_CAUSE_ACCESS
    BK_CAUSE_ACCESS_RANGE
    BK_CAUSE_ADDRESS
    BK_CAUSE_VECTOR
    BK_CAUSE_TRAP
id : the breakpoint id returned by setBreakpoint*
mode : this is used only when type==BK_CAUSE_ACCESS
In this case, it should be one of these values :
    BK_READ_BYTE
    BK_READ_WORD
    BK_READ_LONG_WORD
    BK_WRITE_BYTE
    BK_WRITE_WORD
    BK_WRITE_LONG_WORD
Implementation : should works


void delBreakpointAddress(int address)

Delete an address breakpoint.
id : breakpoint id.
Implementation : should works


void delBreakpointAccess(int id)

Delete an access breakpoint.
id : breakpoint id.
Implementation : okay


void delBreakpointAccessRange(int id)

Delete an access range breakpoint.
id : breakpoint id.
Implementation : okay


void delBreakpointVector(int id)

Delete a vector breakpoint.
id : breakpoint id.
Implementation : NOT IMPLEMENTED YET


void delBreakpointTrap(int id)

Delete a trap breakpoint.
id : breakpoint id.
Implementation : NOT IMPLEMENTED YET
 
 
 
 
 

4) Low level access

void setDataRegister(int n,int val)

Set the value of Dn.
n : index of the data register (0,1,2,3,4,5,6 or 7).
val : the new value
Implementation : ok, no bugs


void setAddressRegister(int n,int val)

Set the value of An.
n : index of the address register (0,1,2,3,4,5,6 or 7).
val : the new value
Implementation : ok, no bugs


void setSpRegister(int val)

Set the value of SP (supervisor stack pointer).
val : the new value
Implementation : ok, no bugs


void setPcRegister(int val)

Set the value of PC (program counter).
val : the new value
Implementation : ok, no bugs


void setSrRegister(int val)

Set the value of SR.
val : the new value
Implementation : ok, no bugs


void setFlagRegister(unsigned char flag)

Implementation : NOT IMPLEMENTED YET (i need more doc about the 68000 flags  ...)


int getDataRegister(int n)

Get the value of Dn.
n : index of the data register (0,1,2,3,4,5,6 or 7).
Return : the value
Implementation : ok, no bugs


int getAddressRegister(int n)

Get the value of An.
n : index of the address register (0,1,2,3,4,5,6 or 7).
Return : the value
Implementation : ok, no bugs


int getSpRegister(void)

Get the value of SP (supervisor stack pointer).
Return : the value
Implementation : ok, no bugs


int getPcRegister(void)

Get the value of PC (program counter).
Return : the new value
Implementation : ok, no bugs


int getSrRegister(void)

Get the value of SR.
Return : the new value
Implementation : ok, no bugs


unsigned char getFlagRegister(void)

Implementation : NOT IMPLEMENTED YET (i need more doc about the 68000 flags  ...)


void* getRam(void)

Return : a pointer to the RAM.
Implementation : ok, no bugs


void* getRom(void)

Return : a pointer to the ROM.
Implementation : ok, no bugs


void*getLcdmem(void)

Return : a pointer to the lcd memory (in most case, it is : getRam()+0x4c00).
Implementation : ok, no bugs


char getContrast(void)

Return : return the contrast level, the value returned is between 0 and 15.
Implementation : ok, no bugs


void setActiveKey(int key,int active)

M&&odify the state of a key.
key : see keydef.h for more details
active : non-zero to enable the key, zero to disable the key
Implementation : ok, no bugs