Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9837 | turbocat | 1 | /********************************************************************************/ |
2 | /* */ |
||
3 | /* CZ80 exec include source file */ |
||
4 | /* C Z80 emulator version 0.91 */ |
||
5 | /* Copyright 2004-2005 Stephane Dallongeville */ |
||
6 | /* */ |
||
7 | /********************************************************************************/ |
||
8 | |||
9 | int FASTCALL Cz80_Exec(cz80_struc *cpu, int cycles) |
||
10 | { |
||
11 | #if CZ80_USE_JUMPTABLE |
||
12 | #include "cz80jmp.inc" |
||
13 | #endif |
||
14 | |||
15 | cz80_struc *CPU; |
||
16 | uint16_t PC; |
||
17 | int CCnt; |
||
18 | uint8_t Opcode; |
||
19 | |||
20 | CPU = cpu; |
||
21 | PC = CPU->PC; |
||
22 | |||
23 | if (CPU->Status & (CZ80_RUNNING | CZ80_DISABLE | CZ80_FAULTED)) |
||
24 | { |
||
25 | return -(CPU->Status); |
||
26 | } |
||
27 | |||
28 | #if CZ80_SIZE_OPT |
||
29 | CPU->CycleToDo = CPU->CycleSup = cycles; |
||
30 | CCnt = 0; |
||
31 | #else |
||
32 | CPU->CycleToDo = CCnt = cycles; |
||
33 | CPU->CycleSup = 0; |
||
34 | #endif |
||
35 | CPU->Status |= CZ80_RUNNING; |
||
36 | |||
37 | #if CZ80_SIZE_OPT |
||
38 | Cz80_Exec_Check: |
||
39 | if (CCnt <= 0) goto Cz80_Exec_End; |
||
40 | #else |
||
41 | goto Cz80_Exec_End; |
||
42 | #endif |
||
43 | |||
44 | Cz80_Exec: |
||
45 | { |
||
46 | Opcode = FETCH_BYTE; |
||
47 | Cz80_Exec_IM0: |
||
48 | { |
||
49 | union16 *data = pzHL; |
||
50 | |||
51 | #include "cz80_op.inc" |
||
52 | } |
||
53 | } |
||
54 | |||
55 | Cz80_Exec_End: |
||
56 | CHECK_INT |
||
57 | if ((CCnt += CPU->CycleSup) > 0) |
||
58 | { |
||
59 | CPU->CycleSup = 0; |
||
60 | if (!(CPU->Status & CZ80_HALTED)) goto Cz80_Exec; |
||
61 | |||
62 | // CPU halted |
||
63 | CCnt = 0; |
||
64 | } |
||
65 | |||
66 | Cz80_Exec_Really_End: |
||
67 | CPU->Status &= ~CZ80_RUNNING; |
||
68 | CPU->PC = PC; |
||
69 | |||
70 | // number of executed cycles |
||
71 | CCnt = CPU->CycleToDo - CCnt; |
||
72 | |||
73 | // update R register |
||
74 | zR = (zR + (CCnt >> 2)) & 0x7F; |
||
75 | |||
76 | return CCnt; |
||
77 | }=> |
||
78 |