fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

devices: Add function mem_get_ptr()

Hampa Hug 9e21351e 872aa8bf

+32 -2
+22 -1
src/devices/memory.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/devices/memory.c * 7 7 * Created: 2000-04-23 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2000-2011 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2000-2013 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 679 679 mem_blk_t *mem_get_blk (memory_t *mem, unsigned long addr) 680 680 { 681 681 return (mem_get_blk_inline (mem, addr, 0)); 682 + } 683 + 684 + void *mem_get_ptr (memory_t *mem, unsigned long addr, unsigned long size) 685 + { 686 + mem_blk_t *blk; 687 + 688 + if ((blk = mem_get_blk (mem, addr)) == NULL) { 689 + return (NULL); 690 + } 691 + 692 + if (blk->data == NULL) { 693 + return (NULL); 694 + } 695 + 696 + addr -= blk->addr1; 697 + 698 + if ((blk->size - addr) < size) { 699 + return (NULL); 700 + } 701 + 702 + return (blk->data + addr); 682 703 } 683 704 684 705 unsigned char mem_get_uint8 (memory_t *mem, unsigned long addr)
+10 -1
src/devices/memory.h
··· 5 5 /***************************************************************************** 6 6 * File name: src/devices/memory.h * 7 7 * Created: 2000-04-23 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2000-2012 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2000-2013 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 305 305 * @return blk The memory block or NULL 306 306 *****************************************************************************/ 307 307 mem_blk_t *mem_get_blk (memory_t *mem, unsigned long addr); 308 + 309 + /*!*************************************************************************** 310 + * @short Get a pointer to memory 311 + * @param mem The memory structure 312 + * @param addr The pointer address 313 + * @param size The requested block size 314 + * @return A pointer to a block of memory at address addr and of size size 315 + *****************************************************************************/ 316 + void *mem_get_ptr (memory_t *mem, unsigned long addr, unsigned long size); 308 317 309 318 unsigned char mem_get_uint8 (memory_t *mem, unsigned long addr); 310 319 unsigned short mem_get_uint16_be (memory_t *mem, unsigned long addr);