Mercurial > repos > blastem
annotate zruntime.S @ 508:b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 03 Feb 2014 09:18:10 -0800 |
parents | cc6030bd04c6 |
children | b3738ee58195 |
rev | line source |
---|---|
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
1 z_inccycles_io: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
2 cmp %edi, %ebp |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
3 jnb do_limit |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
4 no_sync_io: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
5 add $4, %ebp |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
6 ret |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
7 do_limit_io: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
8 cmp 112(%rsi), %ebp |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
9 jb no_sync_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
10 jmp sync_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
11 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 z_inccycles: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 cmp %edi, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 jnb do_limit |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 no_sync: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 add $3, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 do_limit: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 cmp 112(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 jb no_sync |
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
21 sync_io: |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
22 movw $0, 164(%rsi) |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 call z80_save_context_scratch |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 pop %rax /*return address in read/write func*/ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 pop 104(%rsi) /*return address in native code*/ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 sub $5, %rax /* adjust return addres to point to the call instruction that got us here */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 mov %rax, (%rsi) |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
28 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 pop %r15 /* restore callee saved regsiters */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 pop %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 pop %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 pop %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 ret /* return to caller of z80_run */ |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
36 |
508
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
37 forced_sync: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
38 movw $0, 164(%rsi) |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
39 call z80_save_context_scratch |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
40 pop %rax /*return address in read/write func*/ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
41 pop 104(%rsi) /*return address in native code*/ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
42 mov %rax, (%rsi) |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
43 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
44 pop %r15 /* restore callee saved regsiters */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
45 pop %r14 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
46 pop %r13 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
47 pop %r12 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
48 pop %rbp |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
49 pop %rbx |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
50 ret /* return to caller of z80_run */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
51 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 .global z80_handle_cycle_limit_int |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 z80_handle_cycle_limit_int: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 cmp 116(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 jb zskip_int |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 mov 112(%rsi), %ebp /* set cycle limit to sync cycle */ |
375
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
57 /* not sure this is really necessary now that IFF1 and IFF2 are geting cleared */ |
335 | 58 movl $0xFFFFFFFF, 116(%rsi) /* make sure the interrupt doesn't fire more than once */ |
375
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
59 /* disable interrupts */ |
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
60 movb $0, 96(%rsi) |
134ffb72d7a1
Clear IFF1 and IFF2 when an interrupt is taken on the Z80
Mike Pavone <pavone@retrodev.com>
parents:
357
diff
changeset
|
61 movb $0, 97(%rsi) |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 add $7, %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 sub $2, %r9w |
259
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
64 mov %r9w, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 call z_inccycles |
259
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
66 push %r13 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 call z80_write_byte_noinc |
259
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
68 pop %r13 |
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
69 mov %r9w, %r14w |
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
70 add $1, %r14w |
d9417261366f
Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called.
Mike Pavone <pavone@retrodev.com>
parents:
253
diff
changeset
|
71 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 call z80_write_byte_noinc |
276
eec7072189a1
Fix crash bug in Z80 interrupt support
Mike Pavone <pavone@retrodev.com>
parents:
261
diff
changeset
|
74 pop %r14 /*dispose of return address */ |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 /* TODO: Support interrupt mode 0 and 2 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 mov $0x38, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 call z80_native_addr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 jmp *%r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 zskip_int: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 cmp 112(%rsi), %ebp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 jb zskip_sync |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
82 mov %r13w, 164(%rsi) |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 .global z80_do_sync |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 z80_do_sync: |
281
44f0bbf57b4f
Save context in z80_do_sync
Mike Pavone <pavone@retrodev.com>
parents:
280
diff
changeset
|
85 call z80_save_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 pop (%rsi) /*return address in native code*/ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 pop %r15 /* restore callee saved regsiters */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 pop %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 pop %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 pop %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 zskip_sync: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 |
285
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
96 .global z80_halt |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
97 z80_halt: |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
98 mov %edi, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
99 sub %ebp, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
100 and $0xFFFFFFFC, %r14d |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
101 add %r14d, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
102 cmp %edi, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
103 jnb z80_handle_cycle_limit_int |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
104 add $4, %ebp |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
105 jmp z80_handle_cycle_limit_int |
021aeb6df19b
Implement HALT (sort of tested)
Mike Pavone <pavone@retrodev.com>
parents:
284
diff
changeset
|
106 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 .global z80_read_byte |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 z80_read_byte: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 z80_read_byte_noinc: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 cmp $0x4000, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 jb z80_read_ram |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 cmp $0x8000, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 jae z80_read_bank |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
115 cmp $0x6000, %r13w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
116 jb z80_read_ym2612 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 /* TODO: Bank reg, YM-2612, PSG/VDP */ |
280 | 118 mov $0xFF, %r13b |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 z80_read_ram: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 and $0x1FFF, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 mov (%r11, %r13), %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 z80_read_bank: |
508
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
125 push %rsi |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
126 mov 144(%rsi), %rsi /* get system context pointer */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
127 cmp $0, 120(%rsi) /* check bus busy flag */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
128 pop %rsi |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
129 jne bus_busy |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
130 /* approximation of wait states for normal 68K bus access */ |
507
cc6030bd04c6
Add 3 wait states to Z80 access to bank area since that seems to be roughly the average in normal usage
Michael Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
131 add $3, %ebp |
508
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
132 z80_read_bank_cont: |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 and $0x7FFF, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 cmp $0, %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 je slow_bank_read |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 /* 68K memory is byte swapped */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 xor $1, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 mov (%r12, %r13), %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 slow_bank_read: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 /* TODO: Call into C to implement this */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 ret |
508
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
143 bus_busy: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
144 mov %edi, %ebp |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
145 call forced_sync |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
146 jp z80_read_bank_cont |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
147 z80_read_ym2612: |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
148 call z80_save_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
149 mov %r13w, %di |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
150 push %rsi |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
151 call z80_read_ym |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
152 pop %rsi |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
153 mov %al, %r13b |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
154 call z80_load_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
155 ret |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 .global z80_write_byte |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 z80_write_byte: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 z80_write_byte_noinc: |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
161 cmp $0x4000, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 jb z80_write_ram |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
163 cmp $0x8000, %r14w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 jae z80_write_bank |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
165 cmp $0x6000, %r14w |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
166 jb z80_write_ym2612 |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
167 cmp $0x6100, %r14w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
168 jb z80_write_bank_reg |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
169 cmp $0x7F00, %r14w |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
170 jae z80_write_vdp |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 z80_write_ram: |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
173 and $0x1FFF, %r14 |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
174 mov %r13b, (%r11, %r14) |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
175 mov %r14d, %r13d |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
176 shr $7, %r13d |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
177 bt %r13d, 152(%rsi) |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
178 jnc not_code |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
179 call z80_save_context |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
180 mov %r14d, %edi |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
181 call z80_handle_code_write |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
182 mov %rax, %rsi |
261
f0c53a4bbfa3
Implement LDIR and fix a bug in which context was not restored after a call to z80_handle_code_write
Mike Pavone <pavone@retrodev.com>
parents:
259
diff
changeset
|
183 call z80_load_context |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
184 not_code: |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 z80_write_bank: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 slow_bank_write: |
507
cc6030bd04c6
Add 3 wait states to Z80 access to bank area since that seems to be roughly the average in normal usage
Michael Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
188 /* approximation of wait states for 68K bus access */ |
cc6030bd04c6
Add 3 wait states to Z80 access to bank area since that seems to be roughly the average in normal usage
Michael Pavone <pavone@retrodev.com>
parents:
451
diff
changeset
|
189 add $3, %ebp |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 /* TODO: Call into C to implement this */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 ret |
290
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
192 z80_write_ym2612: |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
193 and $0x3, %r14w |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
194 call z80_save_context |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
195 mov %r14w, %di |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
196 mov %r13b, %dl |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
197 call z80_write_ym |
171f97e70d85
Implement writes from Z80 to YM-2612
Mike Pavone <pavone@retrodev.com>
parents:
285
diff
changeset
|
198 mov %rax, %rsi |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
199 jmp z80_load_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 z80_write_bank_reg: |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
201 and $1, %r13w |
280 | 202 shr %r15w |
203 shl $8, %r13w | |
204 xor %r12, %r12 | |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
205 or %r13w, %r15w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 and $0x1FF, %r15w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 cmp $0x80, %r15w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 jb update_bank_ptr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 update_bank_ptr: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 mov %r15w, %r12w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 shl $15, %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 add 80(%rsi), %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 ret |
357
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
215 z80_write_vdp: |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
216 and $0xFF, %r14w |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
217 call z80_save_context |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
218 mov %r14w, %di |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
219 mov %r13b, %dl |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
220 call z80_vdp_port_write |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
221 mov %rax, %rsi |
fa7ea48be9a9
Allow VDP/PSG writes from Z80
Mike Pavone <pavone@retrodev.com>
parents:
335
diff
changeset
|
222 jmp z80_load_context |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 .global z80_read_word |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 z80_read_word: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 call z_inccycles |
508
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
227 cmp $0x8000, %r13w |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
228 jae z80_read_bank_word |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 call z80_read_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 mov %r13b, %r14b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 inc %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 call z80_read_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 shl $8, %r13w |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 mov %r14b, %r13b |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 |
508
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
240 z80_read_bank_word: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
241 push %rsi |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
242 mov 144(%rsi), %rsi /* get system context pointer */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
243 cmp $0, 120(%rsi) /* check bus busy flag */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
244 pop %rsi |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
245 jne bus_busy_word |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
246 add $3, %ebp /* first read typically has 3 wait states */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
247 z80_read_bank_word_cont: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
248 push %r13 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
249 call z80_read_bank_cont |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
250 mov %r13b, %r14b |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
251 pop %r13 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
252 inc %r13 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
253 call z_inccycles |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
254 push %rsi |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
255 mov 144(%rsi), %rsi /* get system context pointer */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
256 cmp $0, 120(%rsi) /* check bus busy flag */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
257 pop %rsi |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
258 jne bus_busy_word2 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
259 add $4, %ebp /* second read typically has 4 wait states */ |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
260 z80_read_bank_word_cont2: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
261 call z80_read_bank_cont |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
262 shl $8, %r13w |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
263 mov %r14b, %r13b |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
264 ret |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
265 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
266 bus_busy_word: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
267 mov %edi, %ebp |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
268 call forced_sync |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
269 jp z80_read_bank_word_cont |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
270 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
271 bus_busy_word2: |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
272 mov %edi, %ebp |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
273 call forced_sync |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
274 jp z80_read_bank_word_cont2 |
b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
Michael Pavone <pavone@retrodev.com>
parents:
507
diff
changeset
|
275 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 .global z80_write_word_highfirst |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 z80_write_word_highfirst: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 push %r13 |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
281 add $1, %r14w |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
282 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 pop %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 .global z80_write_word_lowfirst |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 z80_write_word_lowfirst: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 pop %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 pop %r14 |
253
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
298 add $1, %r14w |
3b34deba4ca0
Squashing some bugs introduced when I switched the register assignments for z80_write_byte around.
Mike Pavone <pavone@retrodev.com>
parents:
252
diff
changeset
|
299 shr $8, %r13w |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 call z_inccycles |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 call z80_write_byte_noinc |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 ret |
284
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
303 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
304 .global z80_io_read |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
305 z80_io_read: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
306 call z_inccycles_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
307 /* genesis Z80 has no IO port hardware and always returns FF */ |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
308 mov $0xFF, %r13 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
309 ret |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
310 |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
311 .global z80_io_write |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
312 z80_io_write: |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
313 call z_inccycles_io |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
314 /* genesis Z80 has no IO port hardware and writes have no effect */ |
ed7098f717d7
Implement IN and OUT (untested)
Mike Pavone <pavone@retrodev.com>
parents:
281
diff
changeset
|
315 ret |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
316 |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
317 .global z80_retrans_stub |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
318 z80_retrans_stub: |
390
561fe3ea3fc8
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
Mike Pavone <pavone@retrodev.com>
parents:
375
diff
changeset
|
319 pop %r14 |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
320 call z80_save_context |
390
561fe3ea3fc8
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
Mike Pavone <pavone@retrodev.com>
parents:
375
diff
changeset
|
321 /* adjust for mov and call instructions */ |
393
30c250a41629
Fix address adjustement in z80_retrans_stub
Mike Pavone <pavone@retrodev.com>
parents:
390
diff
changeset
|
322 sub $11, %r14 |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
323 mov %r13d, %edi |
390
561fe3ea3fc8
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
Mike Pavone <pavone@retrodev.com>
parents:
375
diff
changeset
|
324 mov %r14, %rdx |
252
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
325 push %rsi |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
326 call z80_retranslate_inst |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
327 pop %rsi |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
328 mov %rax, %r13 |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
329 call z80_load_context |
63b9a500a00b
Implement retranslating code when written to. Possibly broken, need to fix some other bugs before a proper test.
Mike Pavone <pavone@retrodev.com>
parents:
249
diff
changeset
|
330 jmp *%r13 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 .global z80_native_addr |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 z80_native_addr: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 call z80_save_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 push %rsi |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
336 mov %rsi, %rdi |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 movzx %r13w, %esi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 call z80_get_native_address_trans |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 mov %rax, %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 pop %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 call z80_load_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 z80_save_context_scratch: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 mov %r13w, 98(%rsi) /* scratch1 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 mov %r14w, 100(%rsi) /* scratch2 */ |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
347 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 .global z80_save_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 z80_save_context: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 mov %r9w, 8(%rsi) /* SP */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 mov %r15w, 16(%rsi) /* bank register */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 mov %bx, 18(%rsi) /* BC */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 mov %cx, 20(%rsi) /* DE */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 mov %ax, 22(%rsi) /* HL */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 mov %dx, 24(%rsi) /* IX */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 mov %r8w, 26(%rsi) /* IY */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
357 mov %r10b, 30(%rsi) /* A */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
358 mov %edi, 48(%rsi) /* target_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
359 mov %ebp, 52(%rsi) /* current_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
360 mov %r12, 72(%rsi) /* cartridge bank pointer */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
361 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 z80_load_context_scratch: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 mov 98(%rsi), %r13w /* scratch1 */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 mov 100(%rsi), %r14w /* scratch2 */ |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
367 |
249
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 .global z80_load_context |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
369 z80_load_context: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
370 mov 8(%rsi), %r9w /* SP */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
371 mov 16(%rsi), %r15w /* bank register */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
372 mov 18(%rsi), %bx /* BC */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
373 mov 20(%rsi), %cx /* DE */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
374 mov 22(%rsi), %ax /* HL */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 mov 24(%rsi), %dx /* IX */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
376 mov 26(%rsi), %r8w /* IY */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
377 mov 30(%rsi), %r10b /* A */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 mov 48(%rsi), %edi /* target_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
379 mov 52(%rsi), %ebp /* current_cycle */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
380 mov 64(%rsi), %r11 /* z80 RAM */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
381 mov 72(%rsi), %r12 /* cartridge bank pointer */ |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
382 ret |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
383 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 .global z80_run |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 z80_run: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 push %rbx |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 push %rbp |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
388 push %r12 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 push %r13 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 push %r14 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
391 push %r15 |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 mov %rdi, %rsi |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
393 call z80_load_context_scratch |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 cmpq $0, 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 je no_extra |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 push 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
397 movq $0, 104(%rsi) |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 no_extra: |
d94e6cd5a8a5
Forgot to commit zruntime a while back, adding it now.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 jmp *(%rsi) |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
393
diff
changeset
|
400 |