; -----------------------------------------------
; PShell - a runtime environment for    
; sharp pocket computers                 
; file     : pshell.h                   
; author   : puehringer edgar           
; date     : 06.06.2004                 
; version  : 1.0.0                      
; assembler: as61860                    
;                                       
; This is the file with global definitions
; for all pshell functions
; -----------------------------------------------

.include "target.h"
.include "regs.h"

; -----------------------------------------------
; Generic functions
; -----------------------------------------------

; The location where to peek/poke call interface
; parameters
.globl ps_ci_param

; Does some cleanup jobs and exits pshell.
; if A is 0xff then the poweroff ROM function
; is executed
.globl ps_exit, ps_break

; calculate the address of a pshell program
.globl ps_addr

; executes a pshell program. The number of the
; program is given in A
.globl ps_exec

; emit a short beep
.globl ps_beep

; toggles the beeps on and off
.globl ps_toggle_sound

; sleeps A * 10ms
; Used Registers: A, B
.globl ps_sleep


; -----------------------------------------------
; Display functions
; -----------------------------------------------

.globl ps_scroll, ps_clrscr

; display a byte pattern with address given in 
; X+1, length in A and x pos in B
.globl ps_gdraw

; same as gdraw, but uses the text cursor 
; of B instead
.globl ps_gprint

; x location of the (text) cursor; not a
; function, just a memory location
.globl ps_cur_x

; y location of the (text) cursor; not a
; function, just a memory location
.globl ps_cur_y

; Converts x cursor position to graphics
; cursor position
.globl ps_xcur2xgcur

.globl ps_putchar_con


; -----------------------------------------------
; Keyboard functions
; -----------------------------------------------

; Checks if a key is pressed on the keyboard
; if Carry Flag = 0, no key was pressed
; if Carry Flag = 1, a key was pressed
; The key code stays in A
; Used Registers: Various because a ROM call
;   is used
; Return value: A, Carry
.globl ps_kbd_nowait

; Waits on a key to be pressed on the keyboard.
; If a key is pressed while entering the
; function, it waits until it is released
; The key code stays in A
; Used Registers: Various because a ROM call
;   is used
; Return value: A
.globl ps_kbd_raw

; Read a character from the keyboard (blocking)
; Used Registers: Various because a ROM call
;   is used
; Return value: A
.globl ps_getchar


; -----------------------------------------------
; Serial port functions
; -----------------------------------------------

; Writes a character in A to the serial port
.globl ps_putchar_aux

; Read a character from the serial port (blocking)
.globl ps_getchar_aux


; -----------------------------------------------
; Printer functions
; -----------------------------------------------

; Writes a character in A to the printer
.globl ps_putchar_prn


; -----------------------------------------------
; Output functions
; -----------------------------------------------

.globl ps_putchar, ps_putstr

; -----------------------------------------------
; Functions to avoid absolute memory access
; -----------------------------------------------

; Takes a relative address in BA and returns the
; absolute address - 1 in X
; Used Registers: A,B,X
.globl ps_rel_ab2abs_x

; Takes a relative address in BA and returns the
; absolute address - 1 in Y
; Used Registers: A,B,Y
.globl ps_rel_ab2abs_y

; Copies the content of AB to X
; Used Registers: AB,X,P,Q
.globl ps_cp_ab_to_x

; Copies the content of AB to Y
; Used Registers: AB,Y,P,Q
.globl ps_cp_ab_to_y

; Copies the content of X to Y
; Used Registers: X,Y,P,Q
.globl ps_cp_x_to_y

; Copies the content of Y to X
; Used Registers: X,Y,P,Q
.globl ps_cp_y_to_x

; -----------------------------------------------
; Conversion and string functions
; -----------------------------------------------

.globl ps_word2str
.globl ps_str2word

; Check if the string with address Y starts with
; the string with address X. 
.globl ps_startswith

; Compare to strings with addresses given in X
; and Y. 
.globl ps_cmpstr

; -----------------------------------------------
; Pshell menu
; -----------------------------------------------

.globl psm_length, psm_init

; -----------------------------------------------
; A temp byte and a temp string
; -----------------------------------------------

.globl ps_tmp, ps_tmp_str

; -----------------------------------------------
; Device I/O constants
; -----------------------------------------------

; Output devices

DEVICE_OUT_CON  = 0x00  ; LCD display 
DEVICE_OUT_COM  = 0x01  ; RS232 interface 
DEVICE_OUT_LPT  = 0x02  ; printer like CE-126P

; Input devices

DEVICE_IN_CON  =  0x80  ; keyboard
DEVICE_IN_COM  =  0x81  ; RS232 interface
