21 #include "xemu/../rom/ep128/xep_rom_syms.h" 
   34 #define XEPSYM_ADDR(sym) (xep_rom_addr + (sym) - 0xC000) 
   35 #define XEPSYM_P(sym) (memory + XEPSYM_ADDR(sym)) 
   36 #define COBUF ((char*)XEPSYM_P(xepsym_cobuf)) 
   37 #define SET_XEPSYM_BYTE(sym, value) *XEPSYM_P(sym) = (value) 
   38 #define SET_XEPSYM_WORD(sym, value) do {        \ 
   39         SET_XEPSYM_BYTE(sym, (value) & 0xFF);   \ 
   40         SET_XEPSYM_BYTE((sym) + 1, (value) >> 8);       \ 
   42 #define BIN2BCD(bin) ((((bin) / 10) << 4) | ((bin) % 10)) 
   44 static const char EXOS_NEWLINE[] = 
"\r\n";
 
   48 #define EXOS_ADDR(n)            (0x3FC000 | ((n) & 0x3FFF)) 
   49 #define EXOS_BYTE(n)            memory[EXOS_ADDR(n)] 
   50 #define EXOS_GET_WORD(n)        (EXOS_BYTE(n) | (EXOS_BYTE((n) + 1) << 8)) 
   59                 *(buffer++) = *(s++) & 0x7F;
 
   70         memcpy(
XEPSYM_P(xepsym_error_message_buffer + 1), msg, l);
 
   71         DEBUG(
"XEP: error msg set len=%d len_stored=%d \"%s\"" NL, l, *
XEPSYM_P(xepsym_error_message_buffer), msg);
 
   83                 sprintf(descbuffer, 
"%04d-%02d-%02d %02d:%02d:%02d",
 
   84                         t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
 
   85                         t->tm_hour, t->tm_min, t->tm_sec
 
   99                 name = config_getopt_str(
"ddn");
 
  100         if (!strcasecmp(
name, 
"none"))
 
  105                         memcpy(
XEPSYM_P(xepsym_default_device_name_string + 1), 
name, l);
 
  107                 SET_XEPSYM_WORD(xepsym_jump_on_rom_entry, xepsym_set_default_device_name);
 
  108                 SET_XEPSYM_BYTE(xepsym_set_default_device_name_is_file_handler, strncasecmp(
name, 
"TAPE", 4) ? 1 : 0);
 
  110                 ERROR_WINDOW(
"Too long default device name is tried to be set, ignoring!");
 
  115 static int exos_cmd_name_match ( 
const char *that, 
Uint16 addr )
 
  117         if (strlen(that) != 
Z80_B) 
return 0;
 
  126 static void xep_exos_command_trap ( 
void )
 
  132         DEBUG(
"XEP: COMMAND TRAP: C=%02Xh, B=%02Xh, DE=%04Xh" NL, c, b, de);
 
  137                         if (exos_cmd_name_match(
"XEP", de + 1)) {
 
  149                                         xepsym_cobuf_size - 1,  
 
  161                         } 
else if (exos_cmd_name_match(
"XEP", de + 1)) {
 
  179                                 Z80_DE = xepsym_error_message_buffer;
 
  188         if (
size > xepsym_cobuf_size - 1)
 
  189                 FATAL(
"FATAL: XEP ROM answer is too large, %d bytes.", 
size);
 
  198         DEBUG(
"XEP: ROM trap at PC=%04Xh OPC=%02Xh" NL, 
pc, opcode);
 
  199         if (opcode != xepsym_ed_trap_opcode)
 
  200                 FATAL(
"FATAL: Unknown ED-trap opcode in XEP ROM: PC=%04Xh ED_OP=%02Xh", 
pc, opcode);
 
  202                 case xepsym_trap_enable_rom_write:
 
  203                         DEBUG(
"XEP: write access to XEP ROM was requested" NL);
 
  206                 case xepsym_trap_exos_command:
 
  207                         xep_exos_command_trap();
 
  209                 case xepsym_trap_on_system_init:
 
  212                         if (config_getopt_int(
"skiplogo")) {
 
  213                                 DEBUG(
"XEP: skiplogo option requested logo skip, etting EXOS variable 0xBFEF to 1 on system init ROM call" NL);
 
  218                         FATAL(
"FATAL: Unknown ED-trap location in XEP ROM: PC=%04Xh (ED_OP=%02Xh)", 
pc, opcode);
 
  223                 case xepsym_trap_set_default_device_name_feedback:
 
  226                 case xepsym_fileio_open_channel_remember:
 
  229                 case xepsym_fileio_no_used_call:
 
  232                 case xepsym_fileio_open_channel:
 
  235                 case xepsym_fileio_create_channel:
 
  238                 case xepsym_fileio_close_channel:
 
  241                 case xepsym_fileio_destroy_channel:
 
  244                 case xepsym_fileio_read_character:
 
  247                 case xepsym_fileio_read_block:
 
  250                 case xepsym_fileio_write_character:
 
  253                 case xepsym_fileio_write_block:
 
  256                 case xepsym_fileio_channel_read_status:
 
  259                 case xepsym_fileio_set_channel_status:
 
  262                 case xepsym_fileio_special_function:
 
  265                 case xepsym_fileio_init:
 
  268                 case xepsym_fileio_buffer_moved: