asap_internal.h
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:3k
源码类别:

Windows CE

开发平台:

C/C++

  1. #ifndef _ASAP_INTERNAL_H_
  2. #define _ASAP_INTERNAL_H_
  3. #include "config.h"
  4. #include <string.h> /* memcpy, memset */
  5. #ifndef FALSE
  6. #define FALSE  0
  7. #endif
  8. #ifndef TRUE
  9. #define TRUE   1
  10. #endif
  11. /* SBYTE and UBYTE must be exactly 1 byte long. */
  12. /* SWORD and UWORD must be exactly 2 bytes long. */
  13. /* SLONG and ULONG must be exactly 4 bytes long. */
  14. #define SBYTE signed char
  15. #define SWORD signed short
  16. #define SLONG signed int
  17. #define UBYTE unsigned char
  18. #define UWORD unsigned short
  19. #define ULONG unsigned int
  20. #define Util_malloc malloc
  21. /* Current clock cycle in a scanline.
  22.    Normally 0 <= xpos && xpos < LINE_C, but in some cases xpos >= LINE_C,
  23.    which means that we are already in line (ypos + 1). */
  24. extern int xpos;
  25. /* xpos limit for the currently running 6502 emulation. */
  26. extern int xpos_limit;
  27. /* Number of cycles per scanline. */
  28. #define LINE_C   114
  29. /* STA WSYNC resumes here. */
  30. #define WSYNC_C  106
  31. /* Number of memory refresh cycles per scanline.
  32.    In the first scanline of a font mode there are actually less than DMAR
  33.    memory refresh cycles. */
  34. #define DMAR     9
  35. extern UBYTE wsync_halt;
  36. #define dGetByte(x) (memory[x])
  37. #define dPutByte(x, y) (memory[x] = y)
  38. #ifndef WORDS_BIGENDIAN
  39. #ifdef WORDS_UNALIGNED_OK
  40. #define dGetWord(x) (*(const UWORD *) &memory[x])
  41. #define dPutWord(x, y) (*(UWORD *) &memory[x] = (y))
  42. #define dGetWordAligned(x) dGetWord(x)
  43. #define dPutWordAligned(x, y) dPutWord(x, y)
  44. #else /* WORDS_UNALIGNED_OK */
  45. #define dGetWord(x) (memory[x] + (memory[(x) + 1] << 8))
  46. #define dPutWord(x, y) (memory[x] = (UBYTE) (y), memory[(x) + 1] = (UBYTE) ((y) >> 8))
  47. /* faster versions of dGetWord and dPutWord for even addresses */
  48. /* TODO: guarantee that memory is UWORD-aligned and use UWORD access */
  49. #define dGetWordAligned(x) dGetWord(x)
  50. #define dPutWordAligned(x, y) dPutWord(x, y)
  51. #endif /* WORDS_UNALIGNED_OK */
  52. #else /* WORDS_BIGENDIAN */
  53. /* can't do any word optimizations for big endian machines */
  54. #define dGetWord(x) (memory[x] + (memory[(x) + 1] << 8))
  55. #define dPutWord(x, y) (memory[x] = (UBYTE) (y), memory[(x) + 1] = (UBYTE) ((y) >> 8))
  56. #define dGetWordAligned(x) dGetWord(x)
  57. #define dPutWordAligned(x, y) dPutWord(x, y)
  58. #endif /* WORDS_BIGENDIAN */
  59. extern UBYTE memory[65536 + 2];
  60. #define GetByte(addr) (((addr) & 0xf900) == 0xd000 ? ASAP_GetByte(addr) : memory[addr])
  61. #define PutByte(addr, byte) do { if (((addr) >> 8) == 0xd2) ASAP_PutByte(addr, byte); else memory[addr] = byte; } while (0)
  62. /* Reads a byte from the specified special address (not RAM or ROM). */
  63. UBYTE ASAP_GetByte(UWORD addr);
  64. /* Stores a byte at the specified special address (not RAM or ROM). */
  65. void ASAP_PutByte(UWORD addr, UBYTE byte);
  66. void ASAP_CIM(void);
  67. #endif /* _ASAP_INTERNAL_H_ */