home *** CD-ROM | disk | FTP | other *** search
/ Emulator Universe CD / emulatoruniversecd1998.iso / Speccy / Emulators / winemu / SOURCES / Z80 / JUMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-10  |  3.9 KB  |  144 lines

  1. /* Jump.c: Jump logic emulation.
  2.  *
  3.  * Copyright 1996 Rui Fernando Ferreira Ribeiro.
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #include "env.h"
  21.  
  22. /*=========================================================================*
  23.  *                            jp_nn                                        *
  24.  *=========================================================================*/
  25. void jp_nn()
  26. {
  27. #define jp_nn() PutPC(Getnextword())
  28.  
  29.    T(10);
  30.    jp_nn();
  31. }
  32.  
  33. /*=========================================================================*
  34.  *                            jp_cc_nn                                     *
  35.  *=========================================================================*/
  36.  
  37. #define jp_cc_nn(flag) { \
  38.    T(10); \
  39.    if(flag) \
  40.    { \
  41.       jp_nn(); \
  42.    } \
  43.    else \
  44.       PC += 2; \
  45. }
  46.  
  47.  
  48. void jp_nz_nn() jp_cc_nn(!flags._Z);
  49. void jp_z_nn()  jp_cc_nn(flags._Z);
  50. void jp_nc_nn() jp_cc_nn(!flags._C);
  51. void jp_c_nn()  jp_cc_nn(flags._C);
  52. void jp_po_nn() jp_cc_nn(!flags._P);
  53. void jp_pe_nn() jp_cc_nn(flags._P);
  54. void jp_p_nn()  jp_cc_nn(!flags._S);
  55. void jp_m_nn()  jp_cc_nn(flags._S);
  56.  
  57. #undef jp_cc_nn
  58. #undef jp_nn
  59.  
  60. /*=========================================================================*
  61.  *                            jr_e                                         *
  62.  *=========================================================================*/
  63. void jr_e()
  64. {
  65.  
  66. #define jr_e() PC += ucharToUshort(readbyte(PC++));
  67.  
  68.    T(12);
  69.    jr_e();
  70. }
  71.  
  72. /*=========================================================================*
  73.  *                            jr_cc_e                                      *
  74.  *=========================================================================*/
  75.  
  76. #define jr_cc_e(flag) { \
  77.    if(flag) \
  78.    { \
  79.       T(12); \
  80.       jr_e(); \
  81.    } \
  82.    else \
  83.    { \
  84.       T(7); \
  85.       PC++; \
  86.    } \
  87. }
  88.  
  89.  
  90. void jr_c_e()  jr_cc_e(flags._C);
  91. void jr_nc_e() jr_cc_e(!flags._C);
  92. void jr_z_e()  jr_cc_e(flags._Z);
  93. void jr_nz_e() jr_cc_e(!flags._Z);
  94.  
  95. #undef jr_cc_e
  96.  
  97. /*=========================================================================*
  98.  *                            jp_hl                                        *
  99.  *=========================================================================*/
  100. void jp_hl()
  101. {
  102.    T(4);
  103.    PutPC(HL);
  104. }
  105.  
  106. /*=========================================================================*
  107.  *                            jp_ix                                        *
  108.  *=========================================================================*/
  109. void jp_ix()
  110. {
  111.    T(8);
  112.    PutPC(IX);
  113. }
  114.  
  115. /*=========================================================================*
  116.  *                            jp_iy                                        *
  117.  *=========================================================================*/
  118. void jp_iy()
  119. {
  120.    T(8);
  121.    PutPC(IY);
  122. }
  123.  
  124. /*=========================================================================*
  125.  *                            djnz_e                                       *
  126.  *=========================================================================*/
  127. void djnz_e()
  128. {
  129.    if(--B)
  130.    {
  131.       T(13);
  132.       jr_e();
  133.    }
  134.    else
  135.    {
  136.       T(8);
  137.       PC++;
  138.    }
  139. }
  140.  
  141. #undef jr_e
  142.  
  143. /* EOF : Jump.c */
  144.