1 /* 2 * TilEm II 3 * 4 * Copyright (c) 2011-2012 Benjamin Moody 5 * 6 * This program is free software: you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include <gtk/gtk.h> 21 22 /* TilemMemModel object: an efficient GtkTreeModel interface for 23 viewing and editing calculator's memory */ 24 25 G_BEGIN_DECLS 26 27 /* Column numbers (repeated for each byte in a given row) */ 28 enum { 29 MM_COL_ADDRESS_0 = 0, /* Address (hexadecimal) */ 30 MM_COL_HEX_0, /* Byte value (hexadecimal) */ 31 MM_COL_CHAR_0, /* Byte value (character, converted to 32 UTF-8) */ 33 MM_COL_BYTE_PTR_0, /* Pointer to corresponding memory byte */ 34 MM_COL_EDITABLE_0, /* TRUE if byte is editable */ 35 MM_COLUMNS_PER_BYTE 36 }; 37 38 #define MM_COL_ADDRESS(n) (MM_COL_ADDRESS_0 + (n) * MM_COLUMNS_PER_BYTE) 39 #define MM_COL_HEX(n) (MM_COL_HEX_0 + (n) * MM_COLUMNS_PER_BYTE) 40 #define MM_COL_CHAR(n) (MM_COL_CHAR_0 + (n) * MM_COLUMNS_PER_BYTE) 41 #define MM_COL_BYTE_PTR(n) (MM_COL_BYTE_PTR_0 + (n) * MM_COLUMNS_PER_BYTE) 42 #define MM_COL_EDITABLE(n) (MM_COL_EDITABLE_0 + (n) * MM_COLUMNS_PER_BYTE) 43 44 /* GObject stuff */ 45 46 #define TILEM_TYPE_MEM_MODEL (tilem_mem_model_get_type()) 47 #define TILEM_MEM_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TILEM_TYPE_MEM_MODEL, TilemMemModel)) 48 #define TILEM_MEM_MODEL_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), TILEM_TYPE_MEM_MODEL, TilemMemModelClass)) 49 #define TILEM_IS_MEM_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TILEM_TYPE_MEM_MODEL)) 50 #define TILEM_IS_MEM_MODEL_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), TILEM_TYPE_MEM_MODEL)) 51 #define TILEM_MEM_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TILEM_TYPE_MEM_MODEL, TilemMemModelClass)) 52 53 typedef struct _TilemMemModel { 54 GObject parent; 55 TilemCalcEmulator *emu; 56 gint stamp; 57 int row_size; 58 int num_rows; 59 dword start_addr; 60 dword wrap_addr; 61 gboolean use_logical; 62 GQueue *cache; 63 } TilemMemModel; 64 65 typedef struct _TilemMemModelClass { 66 GObjectClass parent_class; 67 } TilemMemModelClass; 68 69 GType tilem_mem_model_get_type(void) G_GNUC_CONST; 70 71 GtkTreeModel * tilem_mem_model_new(TilemCalcEmulator* emu, 72 int rowsize, dword start, 73 gboolean logical); 74 75 void tilem_mem_model_clear_cache(TilemMemModel *mm); 76 77 G_END_DECLS 78