Mercurial > repos > blastem
annotate vdp.h @ 2688:b42f00a3a937 default tip
Fix default target. Ensure m68k.h and z80.h are built before anything else when no dep info is available
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 31 Mar 2025 21:06:18 -0700 |
parents | 05915f01046d |
children |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
460
diff
changeset
|
1 /* |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
460
diff
changeset
|
2 Copyright 2013 Michael Pavone |
470
541c1ae8abf3
Properly delay 68K on VDP reads. Dummy VDP test port implementation. Initial stab at handling undefined bits of VSRAM and CRAM.
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
3 This file is part of BlastEm. |
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
460
diff
changeset
|
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
460
diff
changeset
|
5 */ |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #ifndef VDP_H_ |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #define VDP_H_ |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #include <stdint.h> |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 #include <stdio.h> |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
1102
diff
changeset
|
11 #include "system.h" |
1427
4e5797b3935a
WIP - New savestate format
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
12 #include "serialize.h" |
2685
da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
Michael Pavone <pavone@retrodev.com>
parents:
2675
diff
changeset
|
13 #include "pixel.h" |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 #define VDP_REGS 24 |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 #define CRAM_SIZE 64 |
1652
d0a69348add8
Optimized render_map_output a bit
Michael Pavone <pavone@retrodev.com>
parents:
1649
diff
changeset
|
17 #define SHADOW_OFFSET CRAM_SIZE |
d0a69348add8
Optimized render_map_output a bit
Michael Pavone <pavone@retrodev.com>
parents:
1649
diff
changeset
|
18 #define HIGHLIGHT_OFFSET (SHADOW_OFFSET+CRAM_SIZE) |
d0a69348add8
Optimized render_map_output a bit
Michael Pavone <pavone@retrodev.com>
parents:
1649
diff
changeset
|
19 #define MODE4_OFFSET (HIGHLIGHT_OFFSET+CRAM_SIZE) |
1906
2d462aa78349
Make VDP VSRAM capacity respect model selection
Michael Pavone <pavone@retrodev.com>
parents:
1890
diff
changeset
|
20 #define MIN_VSRAM_SIZE 40 |
2d462aa78349
Make VDP VSRAM capacity respect model selection
Michael Pavone <pavone@retrodev.com>
parents:
1890
diff
changeset
|
21 #define MAX_VSRAM_SIZE 64 |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 #define VRAM_SIZE (64*1024) |
1267
3772bb926be5
Initial stab at horizontal border emulation. Only works for H40 and still has a few minor holes to fill
Michael Pavone <pavone@retrodev.com>
parents:
1167
diff
changeset
|
23 #define BORDER_LEFT 13 |
3772bb926be5
Initial stab at horizontal border emulation. Only works for H40 and still has a few minor holes to fill
Michael Pavone <pavone@retrodev.com>
parents:
1167
diff
changeset
|
24 #define BORDER_RIGHT 14 |
3772bb926be5
Initial stab at horizontal border emulation. Only works for H40 and still has a few minor holes to fill
Michael Pavone <pavone@retrodev.com>
parents:
1167
diff
changeset
|
25 #define HORIZ_BORDER (BORDER_LEFT+BORDER_RIGHT) |
3772bb926be5
Initial stab at horizontal border emulation. Only works for H40 and still has a few minor holes to fill
Michael Pavone <pavone@retrodev.com>
parents:
1167
diff
changeset
|
26 #define LINEBUF_SIZE (320+HORIZ_BORDER) //H40 + full border |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
27 #define SCROLL_BUFFER_SIZE 32 |
1077
1a66d5165ea7
Cleanup the separation of render backend and VDP code in preparation for having extra debug windows. Make determination of H40/H32 based on number of lines in each mode.
Michael Pavone <pavone@retrodev.com>
parents:
1019
diff
changeset
|
28 #define BORDER_BOTTOM 13 //TODO: Replace with actual value |
1135
8506b305e0e8
Update Mode 4 rendering to match logic analyzer captures
Michael Pavone <pavone@retrodev.com>
parents:
1120
diff
changeset
|
29 #define MAX_DRAWS_H32_MODE4 8 |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 #define MAX_SPRITES_LINE 20 |
37 | 31 #define MAX_SPRITES_LINE_H32 16 |
38
898e3d035f42
Implement sprite index >= sprite limit triggers sprite limit behavior
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
32 #define MAX_SPRITES_FRAME 80 |
898e3d035f42
Implement sprite index >= sprite limit triggers sprite limit behavior
Mike Pavone <pavone@retrodev.com>
parents:
37
diff
changeset
|
33 #define MAX_SPRITES_FRAME_H32 64 |
998
bf63cbf1d7bb
Implement SAT cache. Causes some graphical corruption in Overdrive due to an unrelated bug.
Michael Pavone <pavone@retrodev.com>
parents:
980
diff
changeset
|
34 #define SAT_CACHE_SIZE (MAX_SPRITES_FRAME * 4) |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
36 #define CRAM_BITS 0xEEE |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
37 #define VSRAM_BITS 0x7FF |
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
38 |
230
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
175
diff
changeset
|
39 #define FBUF_SHADOW 0x0001 |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
175
diff
changeset
|
40 #define FBUF_HILIGHT 0x0010 |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
41 #define FBUF_MODE4 0x0100 |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
42 #define FBUF_MASK (FBUF_SHADOW|FBUF_HILIGHT|FBUF_MODE4) |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
43 #define FBUF_TMS (FBUF_MODE4 | FBUF_SHADOW) |
437
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
44 #define DBG_SHADOW 0x10 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
45 #define DBG_HILIGHT 0x20 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
46 #define DBG_PRIORITY 0x8 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
47 #define DBG_SRC_MASK 0x7 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
48 #define DBG_SRC_A 0x1 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
49 #define DBG_SRC_W 0x2 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
50 #define DBG_SRC_B 0x3 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
51 #define DBG_SRC_S 0x4 |
afbea09d7fb4
Restore one of the VDP debugging modes
Mike Pavone <pavone@retrodev.com>
parents:
436
diff
changeset
|
52 #define DBG_SRC_BG 0x0 |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
38
diff
changeset
|
53 |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
54 #define MCLKS_LINE 3420 |
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
55 |
2574
0da40b1978fd
Sprite overflow flag should only be set when there are too many sprites in a line and not when there are just too many sprite pixels. Fixes regression in Madou Monogatari I
Michael Pavone <pavone@retrodev.com>
parents:
2571
diff
changeset
|
56 #define FLAG_SPRITE_OFLOW 0x01 |
317
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
57 #define FLAG_CAN_MASK 0x02 |
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
58 #define FLAG_MASKED 0x04 |
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
59 #define FLAG_WINDOW 0x08 |
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
60 #define FLAG_PENDING 0x10 |
980
928442068afe
Implemented VDP read prefetch and made DMA copy not use the FIFO any more. Now up to 114 out of 122 passing on VDP FIFO Test ROM
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
61 #define FLAG_READ_FETCHED 0x20 |
317
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
62 #define FLAG_DMA_RUN 0x40 |
2040
a61b47d5489e
Fix window bug implementation
Michael Pavone <pavone@retrodev.com>
parents:
2025
diff
changeset
|
63 #define FLAG_WINDOW_EDGE 0x80 |
317
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
64 |
494
8ac0eb05642c
Initial implementation of sprite overflow and sprite collision status register flags
Mike Pavone <pavone@retrodev.com>
parents:
480
diff
changeset
|
65 #define FLAG2_VINT_PENDING 0x01 |
8ac0eb05642c
Initial implementation of sprite overflow and sprite collision status register flags
Mike Pavone <pavone@retrodev.com>
parents:
480
diff
changeset
|
66 #define FLAG2_HINT_PENDING 0x02 |
8ac0eb05642c
Initial implementation of sprite overflow and sprite collision status register flags
Mike Pavone <pavone@retrodev.com>
parents:
480
diff
changeset
|
67 #define FLAG2_READ_PENDING 0x04 |
8ac0eb05642c
Initial implementation of sprite overflow and sprite collision status register flags
Mike Pavone <pavone@retrodev.com>
parents:
480
diff
changeset
|
68 #define FLAG2_SPRITE_COLLIDE 0x08 |
623
66cc60215e5c
Fix most of the breakage caused by the vcounter/hcounter changes
Michael Pavone <pavone@retrodev.com>
parents:
622
diff
changeset
|
69 #define FLAG2_REGION_PAL 0x10 |
1077
1a66d5165ea7
Cleanup the separation of render backend and VDP code in preparation for having extra debug windows. Make determination of H40/H32 based on number of lines in each mode.
Michael Pavone <pavone@retrodev.com>
parents:
1019
diff
changeset
|
70 #define FLAG2_EVEN_FIELD 0x20 |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
1102
diff
changeset
|
71 #define FLAG2_BYTE_PENDING 0x40 |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
72 #define FLAG2_PAUSE 0x80 |
75 | 73 |
74 #define DISPLAY_ENABLE 0x40 | |
75 | |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 enum { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 REG_MODE_1=0, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 REG_MODE_2, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 REG_SCROLL_A, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 REG_WINDOW, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 REG_SCROLL_B, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 REG_SAT, |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
83 REG_STILE_BASE, |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
84 REG_BG_COLOR, |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
85 REG_X_SCROLL, |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
86 REG_Y_SCROLL, |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
87 REG_HINT, |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 REG_MODE_3, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 REG_MODE_4, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 REG_HSCROLL, |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
91 REG_BGTILE_BASE, |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
92 REG_AUTOINC, |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 REG_SCROLL, |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 REG_WINDOW_H, |
75 | 95 REG_WINDOW_V, |
96 REG_DMALEN_L, | |
97 REG_DMALEN_H, | |
98 REG_DMASRC_L, | |
99 REG_DMASRC_M, | |
2009
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
100 REG_DMASRC_H, |
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
101 REG_KMOD_CTRL=29, |
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
102 REG_KMOD_MSG, |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
103 REG_KMOD_TIMER, |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
104 REG_COLOR_TABLE=REG_WINDOW, |
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
105 REG_PATTERN_GEN=REG_SCROLL_B |
2000
e45a317802bd
Fix broken enum definitions that cause multiple definition errors when building with -fno-common which is now the default in GCC 10
Mike Pavone <pavone@retrodev.com>
parents:
1946
diff
changeset
|
106 }; |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
108 //Mode reg 1 |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
109 #define BIT_VSCRL_LOCK 0x80 |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
110 #define BIT_HSCRL_LOCK 0x40 |
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
111 #define BIT_COL0_MASK 0x20 |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
112 #define BIT_HINT_EN 0x10 |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
113 #define BIT_SPRITE_8PX 0x08 |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
114 #define BIT_PAL_SEL 0x04 |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
115 #define BIT_MODE_4 BIT_PAL_SEL |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
116 #define BIT_HVC_LATCH 0x02 |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
117 #define BIT_M3 BIT_HVC_LATCH |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
118 #define BIT_DISP_DIS 0x01 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
119 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
120 //Mode reg 2 |
1318
bfdd450e7dea
Initial work on handling the 128KB VRAM mode bit and some basic prep work for VDP test register support
Michael Pavone <pavone@retrodev.com>
parents:
1267
diff
changeset
|
121 #define BIT_128K_VRAM 0x80 |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
122 #define BIT_16K_VRAM BIT_128K_VRAM |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
123 #define BIT_DISP_EN 0x40 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
124 #define BIT_VINT_EN 0x20 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
125 #define BIT_DMA_ENABLE 0x10 |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
126 #define BIT_M1 BIT_DMA_ENABLE |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
127 #define BIT_PAL 0x08 |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2243
diff
changeset
|
128 #define BIT_M2 BIT_PAL |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
129 #define BIT_MODE_5 0x04 |
1120
e9369d6f0101
Somewhat broken implementation of Mode 4
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
130 #define BIT_SPRITE_SZ 0x02 |
2204
dc4268a778bc
Implement Mode 4 sprite zooming
Michael Pavone <pavone@retrodev.com>
parents:
2194
diff
changeset
|
131 #define BIT_SPRITE_ZM 0x01 |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
132 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
133 //Mode reg 3 |
2025
e7a516f08cec
Implement serial IO, a generic serial device type and external interrupts
Michael Pavone <pavone@retrodev.com>
parents:
2009
diff
changeset
|
134 #define BIT_EINT_EN 0x08 |
413
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
135 #define BIT_VSCROLL 0x04 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
136 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
137 //Mode reg 4 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
138 #define BIT_H40 0x01 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
139 #define BIT_HILIGHT 0x8 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
140 #define BIT_DOUBLE_RES 0x4 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
141 #define BIT_INTERLACE 0x2 |
36fbbced25c2
Initial work on interlace
Mike Pavone <pavone@retrodev.com>
parents:
337
diff
changeset
|
142 |
1322
b1423d432c0e
Initial stab at implementing the output disable/layer selection bits of the VDP test register
Michael Pavone <pavone@retrodev.com>
parents:
1318
diff
changeset
|
143 //Test register |
b1423d432c0e
Initial stab at implementing the output disable/layer selection bits of the VDP test register
Michael Pavone <pavone@retrodev.com>
parents:
1318
diff
changeset
|
144 #define TEST_BIT_DISABLE 0x40 |
b1423d432c0e
Initial stab at implementing the output disable/layer selection bits of the VDP test register
Michael Pavone <pavone@retrodev.com>
parents:
1318
diff
changeset
|
145 |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 typedef struct { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 uint16_t address; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 int16_t x_pos; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 uint8_t pal_priority; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 uint8_t h_flip; |
1866
84f16a804ce5
Rework sprite rendering phase 3 to better match behavior documented by Kabuto/Titan and fix edge case in sprite overflow flag that was breaking the RPS minigame in Alex Kidd
Michael Pavone <pavone@retrodev.com>
parents:
1821
diff
changeset
|
151 uint8_t width; |
84f16a804ce5
Rework sprite rendering phase 3 to better match behavior documented by Kabuto/Titan and fix edge case in sprite overflow flag that was breaking the RPS minigame in Alex Kidd
Michael Pavone <pavone@retrodev.com>
parents:
1821
diff
changeset
|
152 uint8_t height; |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 } sprite_draw; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 typedef struct { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 uint8_t size; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 uint8_t index; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 int16_t y; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 } sprite_info; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 |
471
f065769836e8
Implement FIFO as a ring buffer so the behavior of reads from invalid CRAM and VSRAM bits can be implemented properly
Mike Pavone <pavone@retrodev.com>
parents:
470
diff
changeset
|
161 #define FIFO_SIZE 4 |
f065769836e8
Implement FIFO as a ring buffer so the behavior of reads from invalid CRAM and VSRAM bits can be implemented properly
Mike Pavone <pavone@retrodev.com>
parents:
470
diff
changeset
|
162 |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 typedef struct { |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
164 uint32_t cycle; |
1318
bfdd450e7dea
Initial work on handling the 128KB VRAM mode bit and some basic prep work for VDP test register support
Michael Pavone <pavone@retrodev.com>
parents:
1267
diff
changeset
|
165 uint32_t address; |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
166 uint16_t value; |
138 | 167 uint8_t cd; |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
168 uint8_t partial; |
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
169 } fifo_entry; |
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
170 |
1631
c4ba3177b72d
WIP new VDP plane debug view and support for detached VDP debug views generally
Michael Pavone <pavone@retrodev.com>
parents:
1629
diff
changeset
|
171 enum { |
2194
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
172 VDP_GENESIS, |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
173 VDP_GAMEGEAR, |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
174 VDP_SMS2, |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
175 VDP_SMS, |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
176 VDP_TMS9918A |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
177 }; |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
178 |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2336
diff
changeset
|
179 typedef struct vdp_context vdp_context; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
180 typedef void (*vdp_hook)(vdp_context *); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
181 typedef void (*vdp_reg_hook)(vdp_context *, uint16_t reg, uint16_t value); |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
182 typedef void (*vdp_data_hook)(vdp_context *, uint16_t value); |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2336
diff
changeset
|
183 |
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2336
diff
changeset
|
184 struct vdp_context { |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
185 system_header *system; |
2686
05915f01046d
WIP attempt to move VDP rendering to a separate thread
Michael Pavone <pavone@retrodev.com>
parents:
2685
diff
changeset
|
186 struct vdp_context *renderer; |
1077
1a66d5165ea7
Cleanup the separation of render backend and VDP code in preparation for having extra debug windows. Make determination of H40/H32 based on number of lines in each mode.
Michael Pavone <pavone@retrodev.com>
parents:
1019
diff
changeset
|
187 //pointer to current line in framebuffer |
2685
da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
Michael Pavone <pavone@retrodev.com>
parents:
2675
diff
changeset
|
188 pixel_t *output; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
189 //pointer to current framebuffer |
2685
da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
Michael Pavone <pavone@retrodev.com>
parents:
2675
diff
changeset
|
190 pixel_t *fb; |
1821
4f3443ecb6d6
Separate compositing from final output. Fixes some minor accuracy issues with regards to when background color reg/CRAM changes take effect. Fixes minor glitch in DF Retro Direct Color DMA demo at inactive/active transition
Michael Pavone <pavone@retrodev.com>
parents:
1652
diff
changeset
|
191 uint8_t *done_composite; |
2685
da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
Michael Pavone <pavone@retrodev.com>
parents:
2675
diff
changeset
|
192 pixel_t *debug_fbs[NUM_DEBUG_TYPES]; |
2009
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
193 char *kmod_msg_buffer; |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2336
diff
changeset
|
194 vdp_hook dma_hook; |
2361
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
195 vdp_reg_hook reg_hook; |
3350b3c8faa8
Initial implementation of VDP register write breakpoints
Michael Pavone <pavone@retrodev.com>
parents:
2359
diff
changeset
|
196 vdp_data_hook data_hook; |
2009
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
197 uint32_t kmod_buffer_storage; |
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
198 uint32_t kmod_buffer_length; |
4ace0fef6f8f
Add support for the parts of the KMod debug ports used by SGDK
Mike Pavone <pavone@retrodev.com>
parents:
2000
diff
changeset
|
199 uint32_t timer_start_cycle; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
200 uint32_t output_pitch; |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2236
diff
changeset
|
201 uint32_t debug_fb_pitch[NUM_DEBUG_TYPES]; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
202 fifo_entry fifo[FIFO_SIZE]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
203 int32_t fifo_write; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
204 int32_t fifo_read; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
205 uint32_t address; |
1925
039553703c20
Don't apply address and cd register changes to the 'live' registers until pending flag is cleared, but do preserve the upper address bits in the latch. Fixes regression in Overdrive 2 while preserving fix to Mona in 344 bytes
Michael Pavone <pavone@retrodev.com>
parents:
1906
diff
changeset
|
206 uint32_t address_latch; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
207 uint32_t serial_address; |
2685
da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
Michael Pavone <pavone@retrodev.com>
parents:
2675
diff
changeset
|
208 pixel_t colors[CRAM_SIZE*4]; |
da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
Michael Pavone <pavone@retrodev.com>
parents:
2675
diff
changeset
|
209 pixel_t debugcolors[1 << (3 + 1 + 1 + 1)];//3 bits for source, 1 bit for priority, 1 bit for shadow, 1 bit for hilight |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
210 uint16_t cram[CRAM_SIZE]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
211 uint32_t frame; |
1906
2d462aa78349
Make VDP VSRAM capacity respect model selection
Michael Pavone <pavone@retrodev.com>
parents:
1890
diff
changeset
|
212 uint32_t vsram_size; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
213 uint8_t cd; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
214 uint8_t flags; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
215 uint8_t regs[VDP_REGS]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
216 //cycle count in MCLKs |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
217 uint32_t cycles; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
218 uint32_t pending_vint_start; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
219 uint32_t pending_hint_start; |
1881
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1872
diff
changeset
|
220 uint32_t top_offset; |
2227
eaaf28af3c94
Implement VDP read latency and invalid write delays revealed by Ti_'s instruction timing ROM
Michael Pavone <pavone@retrodev.com>
parents:
2223
diff
changeset
|
221 uint32_t read_latency; |
1906
2d462aa78349
Make VDP VSRAM capacity respect model selection
Michael Pavone <pavone@retrodev.com>
parents:
1890
diff
changeset
|
222 uint16_t vsram[MAX_VSRAM_SIZE]; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
223 uint16_t vscroll_latch[2]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
224 uint16_t vcounter; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
225 uint16_t inactive_start; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
226 uint16_t border_top; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
227 uint16_t border_bot; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
228 uint16_t hscroll_a; |
1885
4178ce857e87
Calculate fine scroll once per line for a small speedup
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
229 uint16_t hscroll_a_fine; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
230 uint16_t hscroll_b; |
1885
4178ce857e87
Calculate fine scroll once per line for a small speedup
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
231 uint16_t hscroll_b_fine; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
232 uint16_t h40_lines; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
233 uint16_t output_lines; |
1866
84f16a804ce5
Rework sprite rendering phase 3 to better match behavior documented by Kabuto/Titan and fix edge case in sprite overflow flag that was breaking the RPS minigame in Alex Kidd
Michael Pavone <pavone@retrodev.com>
parents:
1821
diff
changeset
|
234 sprite_draw sprite_draw_list[MAX_SPRITES_LINE]; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
235 sprite_info sprite_info_list[MAX_SPRITES_LINE]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
236 uint8_t sat_cache[SAT_CACHE_SIZE]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
237 uint16_t col_1; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
238 uint16_t col_2; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
239 uint16_t hv_latch; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
240 uint16_t prefetch; |
2675
dbff641a33df
Implement Z80/PSG clock speed test register bit
Michael Pavone <pavone@retrodev.com>
parents:
2574
diff
changeset
|
241 uint16_t test_regs[8]; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
242 //stores 2-bit palette + 4-bit palette index + priority for current sprite line |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
243 uint8_t linebuf[LINEBUF_SIZE]; |
1821
4f3443ecb6d6
Separate compositing from final output. Fixes some minor accuracy issues with regards to when background color reg/CRAM changes take effect. Fixes minor glitch in DF Retro Direct Color DMA demo at inactive/active transition
Michael Pavone <pavone@retrodev.com>
parents:
1652
diff
changeset
|
244 uint8_t compositebuf[LINEBUF_SIZE]; |
1641
bc9bb4e5856f
Basic version of layer compositing debug view in a separate window
Michael Pavone <pavone@retrodev.com>
parents:
1640
diff
changeset
|
245 uint8_t layer_debug_buf[LINEBUF_SIZE]; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
246 uint8_t hslot; //hcounter/2 |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
247 uint8_t sprite_index; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
248 uint8_t sprite_draws; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
249 int8_t slot_counter; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
250 int8_t cur_slot; |
1872
45be49d3a98b
Forgot to commit the header changes
Michael Pavone <pavone@retrodev.com>
parents:
1869
diff
changeset
|
251 uint8_t sprite_x_offset; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
252 uint8_t max_sprites_frame; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
253 uint8_t max_sprites_line; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
254 uint8_t fetch_tmp[2]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
255 uint8_t v_offset; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
256 uint8_t hint_counter; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
257 uint8_t flags2; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
258 uint8_t double_res; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
259 uint8_t buf_a_off; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
260 uint8_t buf_b_off; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
261 uint8_t pending_byte; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
262 uint8_t state; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
263 uint8_t cur_buffer; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
264 uint8_t tmp_buf_a[SCROLL_BUFFER_SIZE]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
265 uint8_t tmp_buf_b[SCROLL_BUFFER_SIZE]; |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
266 uint8_t enabled_debuggers; |
2243
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2236
diff
changeset
|
267 uint8_t debug_fb_indices[NUM_DEBUG_TYPES]; |
0d1d5dccdd28
Initial implementation of oscilloscope debug view
Michael Pavone <pavone@retrodev.com>
parents:
2236
diff
changeset
|
268 uint8_t debug_modes[NUM_DEBUG_TYPES]; |
1890
7bb4081e9e52
Hopefully final fix for line advancement/frame end calculation
Michael Pavone <pavone@retrodev.com>
parents:
1885
diff
changeset
|
269 uint8_t pushed_frame; |
2194
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
270 uint8_t type; |
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
271 uint8_t cram_latch; |
2557
75dd7536c467
Apparently window v/h size is latched once per line. Fixes glitch in Landstalker
Michael Pavone <pavone@retrodev.com>
parents:
2411
diff
changeset
|
272 uint8_t window_h_latch; |
75dd7536c467
Apparently window v/h size is latched once per line. Fixes glitch in Landstalker
Michael Pavone <pavone@retrodev.com>
parents:
2411
diff
changeset
|
273 uint8_t window_v_latch; |
2675
dbff641a33df
Implement Z80/PSG clock speed test register bit
Michael Pavone <pavone@retrodev.com>
parents:
2574
diff
changeset
|
274 uint8_t selected_test_reg; |
2236
c149c929361c
Fix color bug when switching between Game Gear and other Sega systems
Michael Pavone <pavone@retrodev.com>
parents:
2227
diff
changeset
|
275 int32_t color_map[1 << 12]; |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1638
diff
changeset
|
276 uint8_t vdpmem[]; |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2336
diff
changeset
|
277 }; |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 |
1631
c4ba3177b72d
WIP new VDP plane debug view and support for detached VDP debug views generally
Michael Pavone <pavone@retrodev.com>
parents:
1629
diff
changeset
|
279 |
c4ba3177b72d
WIP new VDP plane debug view and support for detached VDP debug views generally
Michael Pavone <pavone@retrodev.com>
parents:
1629
diff
changeset
|
280 |
2194
01ff005b08f6
Very rudimentary support for Game Gear VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
2040
diff
changeset
|
281 vdp_context *init_vdp_context(uint8_t region_pal, uint8_t has_max_vsram, uint8_t type); |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
722
diff
changeset
|
282 void vdp_free(vdp_context *context); |
1371
5b20840711c1
Remove HINT_FUDGE and make a small adjustment to how VDP syncs with rest of system instead. Worse results on CRAM dot issue, but much less of a hack
Michael Pavone <pavone@retrodev.com>
parents:
1343
diff
changeset
|
283 void vdp_run_context_full(vdp_context * context, uint32_t target_cycles); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 void vdp_run_context(vdp_context * context, uint32_t target_cycles); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 //runs from current cycle count to VBLANK for the current mode, returns ending cycle count |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 uint32_t vdp_run_to_vblank(vdp_context * context); |
75 | 287 //runs until the target cycle is reached or the current DMA operation has completed, whicever comes first |
288 void vdp_run_dma_done(vdp_context * context, uint32_t target_cycles); | |
424
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
413
diff
changeset
|
289 uint8_t vdp_load_gst(vdp_context * context, FILE * state_file); |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
437
diff
changeset
|
290 uint8_t vdp_save_gst(vdp_context * context, FILE * outfile); |
2227
eaaf28af3c94
Implement VDP read latency and invalid write delays revealed by Ti_'s instruction timing ROM
Michael Pavone <pavone@retrodev.com>
parents:
2223
diff
changeset
|
291 int vdp_control_port_write(vdp_context * context, uint16_t value, uint32_t cpu_cycle); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
1102
diff
changeset
|
292 void vdp_control_port_write_pbc(vdp_context * context, uint8_t value); |
2571
3d14db924e57
DMA fill and copy should not block VDP data or control port writes
Michael Pavone <pavone@retrodev.com>
parents:
2557
diff
changeset
|
293 void vdp_data_port_write(vdp_context * context, uint16_t value); |
1117
928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents:
1102
diff
changeset
|
294 void vdp_data_port_write_pbc(vdp_context * context, uint8_t value); |
2675
dbff641a33df
Implement Z80/PSG clock speed test register bit
Michael Pavone <pavone@retrodev.com>
parents:
2574
diff
changeset
|
295 void vdp_test_port_select(vdp_context * context, uint16_t value); |
470
541c1ae8abf3
Properly delay 68K on VDP reads. Dummy VDP test port implementation. Initial stab at handling undefined bits of VSRAM and CRAM.
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
296 void vdp_test_port_write(vdp_context * context, uint16_t value); |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
297 uint16_t vdp_control_port_read(vdp_context * context); |
2227
eaaf28af3c94
Implement VDP read latency and invalid write delays revealed by Ti_'s instruction timing ROM
Michael Pavone <pavone@retrodev.com>
parents:
2223
diff
changeset
|
298 uint16_t vdp_data_port_read(vdp_context * context, uint32_t *cpu_cycle, uint32_t cpu_divider); |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1135
diff
changeset
|
299 uint8_t vdp_data_port_read_pbc(vdp_context * context); |
1154
c83ec07ddbac
Implemented Mode 4 H conter latching
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
300 void vdp_latch_hv(vdp_context *context); |
137 | 301 uint16_t vdp_hv_counter_read(vdp_context * context); |
65
aef6302770c2
Fix issue in which VDP would have trouble emptying FIFO because the VDP cycle count got reset at end of frame.
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
302 void vdp_adjust_cycles(vdp_context * context, uint32_t deduction); |
317
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
303 uint32_t vdp_next_hint(vdp_context * context); |
e5e8b48ad157
Initial stab at horizontal interrupts and improving accuracy of vertical interrupts. Also added the VINT pending flag to status port.
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
304 uint32_t vdp_next_vint(vdp_context * context); |
333 | 305 uint32_t vdp_next_vint_z80(vdp_context * context); |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
306 uint32_t vdp_next_nmi(vdp_context *context); |
953
08346262990b
Remove the int number argument to vdp_int_ack since it is no longer used
Michael Pavone <pavone@retrodev.com>
parents:
922
diff
changeset
|
307 void vdp_int_ack(vdp_context * context); |
322
8e2fa485c0f2
Remove z80_ram reference in SDL renderer to get stateview compiling again. Print out the sprite list in stateview.
Mike Pavone <pavone@retrodev.com>
parents:
317
diff
changeset
|
308 void vdp_print_sprite_table(vdp_context * context); |
327
1b00258b1f29
Added some basic VDP debugging features to debugger. Fixed DMA enable bug
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
309 void vdp_print_reg_explain(vdp_context * context); |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
437
diff
changeset
|
310 void latch_mode(vdp_context * context); |
623
66cc60215e5c
Fix most of the breakage caused by the vcounter/hcounter changes
Michael Pavone <pavone@retrodev.com>
parents:
622
diff
changeset
|
311 uint32_t vdp_cycles_to_frame_end(vdp_context * context); |
1428
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1427
diff
changeset
|
312 void write_cram_internal(vdp_context * context, uint16_t addr, uint16_t value); |
1333
69c25e1188e5
Small tweak to how SAT cache updates are done. Mostly fixes the rotating cube scene in Overdrive 2
Michael Pavone <pavone@retrodev.com>
parents:
1325
diff
changeset
|
313 void vdp_check_update_sat_byte(vdp_context *context, uint32_t address, uint8_t value); |
1377
e587f16e7d3d
Implemented SMS pause button
Michael Pavone <pavone@retrodev.com>
parents:
1371
diff
changeset
|
314 void vdp_pbc_pause(vdp_context *context); |
1401
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1377
diff
changeset
|
315 void vdp_release_framebuffer(vdp_context *context); |
b56c8c51ca5d
Properly release and reacquire framebuffer pointer when switching contexts. Hopefully fixes the LOCKRECT issue some people are seeing with the SDL 2 fallback renderer
Michael Pavone <pavone@retrodev.com>
parents:
1377
diff
changeset
|
316 void vdp_reacquire_framebuffer(vdp_context *context); |
1427
4e5797b3935a
WIP - New savestate format
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
317 void vdp_serialize(vdp_context *context, serialize_buffer *buf); |
4e5797b3935a
WIP - New savestate format
Michael Pavone <pavone@retrodev.com>
parents:
1401
diff
changeset
|
318 void vdp_deserialize(deserialize_buffer *buf, void *vcontext); |
1629
079e5b9d59ce
Forcefully update the display when entering the 68K debugger so you can see it update in realtime as you step through the code
Michael Pavone <pavone@retrodev.com>
parents:
1436
diff
changeset
|
319 void vdp_force_update_framebuffer(vdp_context *context); |
1631
c4ba3177b72d
WIP new VDP plane debug view and support for detached VDP debug views generally
Michael Pavone <pavone@retrodev.com>
parents:
1629
diff
changeset
|
320 void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type); |
c4ba3177b72d
WIP new VDP plane debug view and support for detached VDP debug views generally
Michael Pavone <pavone@retrodev.com>
parents:
1629
diff
changeset
|
321 void vdp_inc_debug_mode(vdp_context *context); |
1649
b500e971da75
Allow closing VDP debug windows with the close button in the window title bar
Michael Pavone <pavone@retrodev.com>
parents:
1643
diff
changeset
|
322 //to be implemented by the host system |
b500e971da75
Allow closing VDP debug windows with the close button in the window title bar
Michael Pavone <pavone@retrodev.com>
parents:
1643
diff
changeset
|
323 uint16_t read_dma_value(uint32_t address); |
2336
83f5529086c5
Make bogus word RAM read more appropriately bogus
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
324 void vdp_dma_started(void); |
1946 | 325 void vdp_replay_event(vdp_context *context, uint8_t event, event_reader *reader); |
2358
4b2ac43c106e
Give debugger expression engine access to VDP and Sub CPU values. Add basic variable support
Michael Pavone <pavone@retrodev.com>
parents:
2336
diff
changeset
|
326 uint16_t vdp_status(vdp_context *context); |
2359
04d29635d238
Support for arrays in debugger language
Michael Pavone <pavone@retrodev.com>
parents:
2358
diff
changeset
|
327 void vdp_reg_write(vdp_context *context, uint16_t reg, uint16_t value); |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
437
diff
changeset
|
328 |
2411
efd2242c2c23
Fix silly TMS9918A bug, make CRAM viewer sorta useful in TMS9918A modes, make mode4 address map externally viewable for debugger
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
329 extern uint16_t mode4_address_map[0x4000]; |
efd2242c2c23
Fix silly TMS9918A bug, make CRAM viewer sorta useful in TMS9918A modes, make mode4 address map externally viewable for debugger
Michael Pavone <pavone@retrodev.com>
parents:
2361
diff
changeset
|
330 |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 #endif //VDP_H_ |