1 /* Hey EMACS -*- linux-c -*- */ 2 /* $Id: ti68k_def.h 2819 2009-05-02 19:51:29Z roms $ */ 3 4 /* TiEmu - Tiemu Is an EMUlator 5 * 6 * Copyright (c) 2000, Thomas Corvazier, Romain Lievin 7 * Copyright (c) 2001-2002, Romain Lievin, Julien Blache 8 * Copyright (c) 2003-2004, Romain Li�vin 9 * Copyright (c) 2005-2007, Romain Li�vin, Kevin Kofler 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 24 */ 25 26 27 #ifndef __TI68K_DEFS__ 28 #define __TI68K_DEFS__ 29 30 #ifdef HAVE_CONFIG_H 31 # include <config.h> 32 #endif 33 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #include <glib.h> 40 #include <stdint.h> 41 42 #include "tilibs.h" 43 #include "mem_size.h" 44 #include "rtc_hw3.h" 45 #include "macros.h" 46 47 /* Equivalences */ 48 49 #ifdef __WIN32__ 50 # define strcasecmp _stricmp 51 #endif 52 53 /* Constants */ 54 55 #define MAXCHARS 256 56 57 #define TI92 (1 << 0) 58 #define TI89 (1 << 1) 59 #define TI92p (1 << 2) 60 #define V200 (1 << 3) 61 #define TI89t (1 << 4) 62 #define CALC_MAX TI89t 63 64 #define EXTERNAL 0 65 #define INTERNAL 1 66 67 #define EPROM_ROM 0 68 #define FLASH_ROM 2 69 70 #define KB (1024) 71 #define MB (1024*KB) 72 73 #define HW1 1 74 #define HW2 2 75 #define HW3 3 76 #define HW4 4 77 78 #define LCDMEM_W 240 // LCD _memory_ width 79 #define LCDMEM_H 128 // LCD _memory_ height 80 81 /* Structures */ 82 83 typedef struct 84 { 85 char *rom_file; 86 char *tib_file; 87 char *sav_file; 88 89 int restricted; // CPU rate of a real calc 90 int cpu_rate; // OSC1 91 int hw_rate; // OSC2 92 int lcd_rate; // synched OSC2 (hw1) or OSC3 (hw2) 93 int hw_protect; // HW protection 94 int recv_file; // receive file enabled/disabled 95 } Ti68kParameters; 96 97 // If this structure is modified, the SAV_REVISION number (state.c) 98 // has to be incremented. 99 typedef struct 100 { 101 // misc (non hardware pseudo-constants) 102 int calc_type; 103 104 int ram_size; // RAM size 105 int rom_size; // ROM size 106 int io_size; // HWx io size 107 int io2_size; // HW2 io size 108 int io3_size; // HW3 io size 109 110 uint32_t rom_base; // ROM base address 111 int rom_flash; // ROM type 112 char rom_version[5]; // ROM/AMS version 113 114 int hw_type; // HW1/2/3/4 115 116 int ti92v1; // ROM v1.x(y) 117 int ti92v2; // ROM v2.x 118 119 int lcd_w; // LCD physical width 120 int lcd_h; // LCD physical height 121 122 // keyboard 123 int on_key; 124 125 // lcd 126 uint32_t lcd_adr; // LCD address (as $4c00) 127 char* lcd_ptr; // direct pointer to LCD in PC RAM 128 int contrast; 129 int log_w; // LCD logical width 130 int log_h; // LCD logical height 131 int on_off; 132 unsigned long lcd_tick;// used by grayscales 133 134 // memory 135 uint8_t* rom; // ROM 136 uint8_t* ram; // RAM 137 uint8_t* io; // HW1/2/3 i/o ports 138 uint8_t* io2; // HW2/3 i/o ports 139 uint8_t* io3; // HW3 i/o ports 140 uint8_t* unused; // unused 141 142 uint32_t initial_ssp;// SSP at vector #0 143 uint32_t initial_pc; // PC at vector #1 144 145 // timer 146 uint8_t timer_value;// Current timer value 147 uint8_t timer_init; // Value to reload 148 149 // rtc (hw2) 150 uint8_t rtc_value; // RTC value 151 152 // rtc (hw3) 153 TTIME rtc3_ref; // time reference 154 TTIME rtc3_beg; // time value when 155 TTIME rtc3_load; // clock is load 156 157 // protection 158 int protect; // hw protection state 159 uint32_t archive_limit; // archive memory limit 160 int ram_exec[64]; // RAM page execution protection bitmask 161 162 } Ti68kHardware; 163 164 typedef struct 165 { 166 // Memory 167 GList *mem_rb; // read byte 168 GList *mem_rw; 169 GList *mem_rl; 170 171 GList *mem_wb; // write byte 172 GList *mem_ww; 173 GList *mem_wl; 174 175 GList *mem_rng_r; // mem range 176 GList *mem_rng_w; 177 178 // Code 179 GList *code; 180 181 // Exceptions 182 GList *exception; 183 184 // Program entry 185 GList *pgmentry; 186 187 // Bits 188 GList *bits; 189 190 // Breakpoint cause 191 int type; // Ti68kBkptType 192 int mode; // Ti68kBkptMode 193 int id; 194 } Ti68kBreakpoints; 195 196 typedef DeviceOptions Ti68kLinkPort; 197 198 typedef struct 199 { 200 // PC 201 int pclog_size; 202 uint32_t* pclog_buf; 203 int pclog_ptr; 204 205 // Link 206 int link_size; // buffer size 207 uint16_t* link_buf; // buffer (LSB is data, MSB is S/R action) 208 int link_ptr; // buffer index 209 int link_mask; // actions (1: S, 2: R) 210 211 } Ti68kLogging; 212 213 /* Externs */ 214 215 extern Ti68kParameters params; 216 extern Ti68kHardware tihw; 217 extern Ti68kLinkPort linkp; 218 extern Ti68kBreakpoints bkpts; 219 extern Ti68kLogging logger; 220 221 /* Misc */ 222 223 #ifndef TRY 224 #define TRY(x) { int aaa_; if((aaa_ = (x))) return aaa_; } 225 #endif 226 227 #ifdef __cplusplus 228 } 229 #endif 230 231 #endif 232