Subversion Repositories pentevo

Rev

Rev 798 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. #pragma once
  2. extern const unsigned char rl0[];
  3. extern const unsigned char rl1[];
  4.  
  5. extern const unsigned char rr0[];
  6. extern const unsigned char rr1[];
  7.  
  8. extern const unsigned char rlcf[];
  9. extern const unsigned char rrcf[];
  10.  
  11. #ifdef __ICL
  12. extern unsigned char rol[];
  13. extern unsigned char ror[];
  14. extern unsigned char rlcaf[];
  15. extern unsigned char rrcaf[];
  16. #else
  17. struct TMakeRot
  18. {
  19.     constexpr TMakeRot();
  20.  
  21.     u8 rol[0x100];
  22.     u8 ror[0x100];
  23.     u8 rlcaf[0x100];
  24.     u8 rrcaf[0x100];
  25. };
  26.  
  27. extern const TMakeRot MakeRot;
  28. #define rol MakeRot.rol
  29. #define ror MakeRot.ror
  30. #define rlcaf MakeRot.rlcaf
  31. #define rrcaf MakeRot.rrcaf
  32. #endif
  33.  
  34. extern const unsigned char sraf[];
  35.  
  36.  
  37. #ifdef __ICL
  38. extern unsigned char log_f[];
  39. #else
  40. struct TLogf
  41. {
  42.     constexpr TLogf();
  43.  
  44.     u8 log_f[0x100];
  45. };
  46.  
  47. extern const TLogf Logf;
  48. #define log_f Logf.log_f
  49. #endif
  50.  
  51. extern const unsigned char incf[];
  52. extern const unsigned char decf[];
  53.  
  54. #ifdef __ICL
  55. extern unsigned char adcf[];
  56. #else
  57.  
  58. struct TMakeAdcf
  59. {
  60.     constexpr TMakeAdcf();
  61.  
  62.     u8 adcf[0x20000];
  63. };
  64.  
  65. extern const TMakeAdcf MakeAdcf;
  66.  
  67. #define adcf MakeAdcf.adcf
  68. #endif
  69.  
  70. #ifdef __ICL
  71. extern unsigned char sbcf[];
  72. extern unsigned char cpf[];
  73. extern unsigned char cpf8b[];
  74. #else
  75.  
  76. struct TMakeSbc
  77. {
  78.     constexpr TMakeSbc();
  79.  
  80.     u8 sbcf[0x20000];
  81.     u8 cpf[0x10000];
  82.     u8 cpf8b[0x10000];
  83. };
  84.  
  85. extern const TMakeSbc MakeSbc;
  86.  
  87. #define sbcf MakeSbc.sbcf
  88. #define cpf MakeSbc.cpf
  89. #define cpf8b MakeSbc.cpf8b
  90. #endif
  91.  
  92. Z80INLINE void and8(Z80 *cpu, unsigned char src)
  93. {
  94.    cpu->a &= src;
  95.    cpu->f = log_f[cpu->a] | HF;
  96. }
  97.  
  98. Z80INLINE void or8(Z80 *cpu, unsigned char src)
  99. {
  100.    cpu->a |= src;
  101.    cpu->f = log_f[cpu->a];
  102. }
  103.  
  104. Z80INLINE void xor8(Z80 *cpu, unsigned char src)
  105. {
  106.    cpu->a ^= src;
  107.    cpu->f = log_f[cpu->a];
  108. }
  109.  
  110. Z80INLINE void bitmem(Z80 *cpu, unsigned char src, unsigned char bit)
  111. {
  112.    cpu->f = log_f[src & (1 << bit)] | HF | (cpu->f & CF);
  113.    cpu->f = (cpu->f & ~(F3|F5)) | (cpu->memh & (F3|F5));
  114. }
  115.  
  116. Z80INLINE void set(unsigned char &src, unsigned char bit)
  117. {
  118.    src |= (1 << bit);
  119. }
  120.  
  121. Z80INLINE void res(unsigned char &src, unsigned char bit)
  122. {
  123.    src &= ~(1 << bit);
  124. }
  125.  
  126. Z80INLINE void bit(Z80 *cpu, unsigned char src, unsigned char bit)
  127. {
  128.    cpu->f = log_f[src & (1 << bit)] | HF | (cpu->f & CF) | (src & (F3|F5));
  129. }
  130.  
  131. Z80INLINE unsigned char resbyte(unsigned char src, unsigned char bit)
  132. {
  133.    return src & ~(1 << bit);
  134. }
  135.  
  136. Z80INLINE unsigned char setbyte(unsigned char src, unsigned char bit)
  137. {
  138.    return u8(src | (1U << bit));
  139. }
  140.  
  141. Z80INLINE void inc8(Z80 *cpu, unsigned char &x)
  142. {
  143.    cpu->f = incf[x] | (cpu->f & CF);
  144.    x++;
  145. }
  146.  
  147. Z80INLINE void dec8(Z80 *cpu, unsigned char &x)
  148. {
  149.    cpu->f = decf[x] | (cpu->f & CF);
  150.    x--;
  151. }
  152.  
  153. Z80INLINE void add8(Z80 *cpu, unsigned char src)
  154. {
  155.    cpu->f = adcf[cpu->a + src*0x100];
  156.    cpu->a += src;
  157. }
  158.  
  159. Z80INLINE void sub8(Z80 *cpu, unsigned char src)
  160. {
  161.    cpu->f = sbcf[cpu->a*0x100 + src];
  162.    cpu->a -= src;
  163. }
  164.  
  165. Z80INLINE void adc8(Z80 *cpu, unsigned char src)
  166. {
  167.    unsigned char carry = ((cpu->f) & CF);
  168.    cpu->f = adcf[cpu->a + src*0x100 + 0x10000*carry];
  169.    cpu->a += src + carry;
  170. }
  171.  
  172. Z80INLINE void sbc8(Z80 *cpu, unsigned char src)
  173. {
  174.    unsigned char carry = ((cpu->f) & CF);
  175.    cpu->f = sbcf[cpu->a*0x100 + src + 0x10000*carry];
  176.    cpu->a -= src + carry;
  177. }
  178.  
  179. Z80INLINE void cp8(Z80 *cpu, unsigned char src)
  180. {
  181.    cpu->f = cpf[cpu->a*0x100 + src];
  182. }
  183.  
  184. void init_z80tables();
  185.