home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / v2600 / source.lha / source / exmacro.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  1.7 KB  |  70 lines

  1. /*****************************************************************************
  2.  
  3.    This file is part of x2600, the Atari 2600 Emulator
  4.    ===================================================
  5.    
  6.    Copyright 1996 Alex Hornby. For contributions see the file CREDITS.
  7.  
  8.    This software is distributed under the terms of the GNU General Public
  9.    License. This is free software with ABSOLUTELY NO WARRANTY.
  10.    
  11.    See the file COPYING for Details.
  12.    
  13.    $Id: exmacro.c,v 1.6 1996/08/26 15:04:20 ahornby Exp $
  14.  
  15.    Tweaked by Matthew Stroup for Amiga v2600, January 27, 1997.
  16.  
  17. ******************************************************************************/
  18.  
  19. /* Things that used to be macros, but are now inline functions.
  20.    Done for ease of debugging */
  21.  
  22. #include "types.h"
  23. #include "extern.h"
  24. #include "macro.h"
  25. #include "memory.h"
  26.  
  27. /* Loads an absolute address uising the quicker load mechanism */
  28. inline ADDRESS
  29. load_abs_addr (void)
  30. {
  31.   return (ADDRESS)(LOADEXEC (PC + 1) | (LOADEXEC (PC + 2) << 8));
  32. }
  33.  
  34. /* Used in variable cycle time indexed addressing */
  35. /* a: address to be incremented */
  36. /* b: increment value */
  37. /* returns: TRUE if an address increment will cross a page boundary */
  38. inline int
  39. pagetest (ADDRESS a, UBYTE b)
  40. {
  41.   return (LOWER (a) + b > 0xff);
  42. }
  43.  
  44. /* Used in variable cycle time branches */
  45. /* a: high byte of new address */
  46. /* returns: TRUE if a branch is to the same page */
  47. inline int
  48. brtest (UBYTE a)
  49. {
  50.   return (UPPER (PC) == (a));
  51. }
  52.  
  53. /* Convert from binary to BCD (Binary Coded Decimal) */
  54. /* a: binary value */
  55. /* returns: BCD value */
  56. inline int
  57. toBCD (int a)
  58. {
  59.   return (((a % 100) / 10) << 4) | (a % 10);
  60. }
  61.  
  62. /* Convert from BCD to binary */
  63. /* a: BCD value */
  64. /* returns: binary value */
  65. inline int
  66. fromBCD (int a)
  67. {
  68.   return ((a >> 4) & 0xf) * 10 + (a & 0xf);
  69. }
  70.