Mercurial > repos > blastem
annotate cd_graphics.c @ 2663:568c1c22f3e3
Allow changing at least some settings in web build without breaking
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 06 Mar 2025 01:33:03 -0800 |
parents | a1afe26a8ef0 |
children | da2e06c42d16 |
rev | line source |
---|---|
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "cd_graphics.h" |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include "backend.h" |
2271
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
3 #include "render.h" |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 void cd_graphics_init(segacd_context *cd) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 cd->graphics_int_cycle = CYCLE_NEVER; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 #define BIT_HFLIP 0x8000 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 static uint8_t get_src_pixel(segacd_context *cd) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 uint16_t x = cd->graphics_x >> 11; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 uint16_t y = cd->graphics_y >> 11; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 cd->graphics_x += cd->graphics_dx; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 cd->graphics_x &= 0xFFFFFF; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 cd->graphics_y += cd->graphics_dy; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 cd->graphics_y &= 0xFFFFFF; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 uint16_t stamp_shift, pixel_mask; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 uint16_t stamp_num_mask; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 if (cd->gate_array[GA_STAMP_SIZE] & BIT_STS) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 //32x32 stamps |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 stamp_shift = 5; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 pixel_mask = 0x1F; |
2271
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
26 stamp_num_mask = 0x7FC; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 //16x16 stamps |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 stamp_shift = 4; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 pixel_mask = 0xF; |
2271
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
31 stamp_num_mask = 0x7FF; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 uint16_t stamp_x = x >> stamp_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 uint16_t stamp_y = y >> stamp_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 uint16_t max, base_mask; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 uint32_t row_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 if (cd->gate_array[GA_STAMP_SIZE] & BIT_SMS) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 max = 4096 >> stamp_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 base_mask = 0xE000 << ((5 - stamp_shift) << 1); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 //128 stamps in 32x32 mode, 256 stamps in 16x16 mode |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 row_shift = 12 - stamp_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 max = 256 >> stamp_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 base_mask = 0xFFE0 << ((5 - stamp_shift) << 1); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 //8 stamps in 32x32 mode, 16 stamps in 16x16 mode |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 row_shift = 8 - stamp_shift; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 } |
2077
c3241eff3c3a
Sega CD graphics processor output now looks correct for some operations
Michael Pavone <pavone@retrodev.com>
parents:
2071
diff
changeset
|
48 if (stamp_x >= max || stamp_y >= max) { |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 if (cd->gate_array[GA_STAMP_SIZE] & BIT_RPT) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 stamp_x &= max - 1; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 stamp_y &= max - 1; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 return 0; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 uint32_t address = (cd->gate_array[GA_STAMP_MAP_BASE] & base_mask) << 1; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 address += (stamp_y << row_shift) + stamp_x; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 uint16_t stamp_def = cd->word_ram[address]; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 uint16_t stamp_num = stamp_def & stamp_num_mask; |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
60 if (!stamp_num) { |
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
61 //manual says stamp 0 can't be used, I assume that means it's treated as transparent |
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
62 return 0; |
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
63 } |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 uint16_t pixel_x = x & pixel_mask; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 uint16_t pixel_y = y & pixel_mask; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 if (stamp_def & BIT_HFLIP) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 pixel_x = pixel_mask - pixel_x; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 uint16_t tmp; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 switch (stamp_def >> 13 & 3) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 case 0: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 case 1: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 tmp = pixel_y; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 pixel_y = pixel_x; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 pixel_x = pixel_mask - tmp; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 case 2: |
2098
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
80 pixel_y = pixel_mask - pixel_y; |
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
81 pixel_x = pixel_mask - pixel_x; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 case 3: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 tmp = pixel_y; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 pixel_y = pixel_mask - pixel_x; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 pixel_x = tmp; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 } |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
89 uint16_t cell_x = pixel_x >> 3; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 uint32_t pixel_address = stamp_num << 6; |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
91 pixel_address += (pixel_y << 1) + (cell_x << (stamp_shift + 1)) + (pixel_x >> 2 & 1); |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 uint16_t word = cd->word_ram[pixel_address]; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 switch (pixel_x & 3) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 default: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 case 0: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 return word >> 12; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 case 1: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 return word >> 8 & 0xF; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 case 2: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 return word >> 4 & 0xF; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 case 3: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 return word & 0xF; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 enum { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 FETCH_X, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 FETCH_Y, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 FETCH_DX, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 FETCH_DY, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 PIXEL0, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 PIXEL1, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 PIXEL2, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 PIXEL3, |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 DRAW |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 }; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 void draw_pixels(segacd_context *cd) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 uint16_t to_draw = 4 - (cd->graphics_dst_x & 3); |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
123 uint16_t x_end = cd->gate_array[GA_IMAGE_BUFFER_HDOTS] + (cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7); |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 if (cd->graphics_dst_x + to_draw > x_end) { |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
125 to_draw = cd->gate_array[GA_IMAGE_BUFFER_HDOTS] + (cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7) - cd->graphics_dst_x; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 for(uint16_t i = 0; i < to_draw; i++) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 uint32_t dst_address = cd->gate_array[GA_IMAGE_BUFFER_START] << 1; |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
130 dst_address += cd->graphics_dst_y << 1; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 dst_address += cd->graphics_dst_x >> 2 & 1; |
2077
c3241eff3c3a
Sega CD graphics processor output now looks correct for some operations
Michael Pavone <pavone@retrodev.com>
parents:
2071
diff
changeset
|
132 dst_address += ((cd->graphics_dst_x >> 3) * (cd->gate_array[GA_IMAGE_BUFFER_VCELLS] + 1)) << 4; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 uint16_t pixel_shift = 12 - 4 * (cd->graphics_dst_x & 3); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 uint16_t pixel = cd->graphics_pixels[i] << pixel_shift; |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
135 uint16_t src_mask_check = 0xF << pixel_shift; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 uint16_t src_mask_keep = ~src_mask_check; |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
137 pixel &= src_mask_check; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 switch (cd->gate_array[1] >> 3 & 3) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 case 0: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 //priority mode off |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 cd->word_ram[dst_address] &= src_mask_keep; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 cd->word_ram[dst_address] |= pixel; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 case 1: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 //underwrite |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 if (pixel && ! (cd->word_ram[dst_address] & src_mask_check)) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 cd->word_ram[dst_address] &= src_mask_keep; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 cd->word_ram[dst_address] |= pixel; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 break; |
2098
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
152 case 2: |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 //overwrite |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 if (pixel) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 cd->word_ram[dst_address] &= src_mask_keep; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 cd->word_ram[dst_address] |= pixel; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 } |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
160 cd->graphics_dst_x++; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 if (cd->graphics_dst_x == x_end) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 cd->graphics_dst_y++; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 --cd->gate_array[GA_IMAGE_BUFFER_LINES]; |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
165 cd->gate_array[GA_TRACE_VECTOR_BASE] += 2; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 cd->graphics_step = FETCH_X; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 cd->graphics_step = PIXEL0; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 #define CHECK_CYCLES cd->graphics_step++; if(cd->graphics_cycle >= cycle) break |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 #define CHECK_ONLY if(cd->graphics_cycle >= cycle) break |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 static void do_graphics(segacd_context *cd, uint32_t cycle) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 if (!cd->gate_array[GA_IMAGE_BUFFER_LINES]) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 return; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 while (cd->graphics_cycle < cycle) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 switch (cd->graphics_step) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 case FETCH_X: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 cd->graphics_x = cd->word_ram[cd->gate_array[GA_TRACE_VECTOR_BASE] << 1] << 8; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 cd->graphics_cycle += 3*4; |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
187 cd->graphics_dst_x = cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 case FETCH_Y: |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
190 cd->graphics_y = cd->word_ram[(cd->gate_array[GA_TRACE_VECTOR_BASE] << 1) + 1] << 8; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 cd->graphics_cycle += 2*4; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 case FETCH_DX: |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
194 cd->graphics_dx = cd->word_ram[(cd->gate_array[GA_TRACE_VECTOR_BASE] << 1) + 2]; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 if (cd->graphics_dx & 0x8000) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 cd->graphics_dx |= 0xFF0000; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 cd->graphics_cycle += 2*4; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 case FETCH_DY: |
2071
598017ef4b0d
Fix a few sega cd graphics processor bugs
Michael Pavone <pavone@retrodev.com>
parents:
2069
diff
changeset
|
201 cd->graphics_dy = cd->word_ram[(cd->gate_array[GA_TRACE_VECTOR_BASE] << 1) + 3]; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 if (cd->graphics_dy & 0x8000) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 cd->graphics_dy |= 0xFF0000; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 cd->graphics_cycle += 2*4; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 case PIXEL0: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 cd->graphics_pixels[0] = get_src_pixel(cd); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 cd->graphics_cycle += 2*4; |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
210 if ((cd->graphics_dst_x & 3) == 3 || (cd->graphics_dst_x + 1 == cd->gate_array[GA_IMAGE_BUFFER_HDOTS] + (cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7))) { |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 cd->graphics_step = DRAW; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 CHECK_ONLY; |
2092
8665d8da0e1c
Fix infinite loop in Sega CD graphics coprocessor code
Michael Pavone <pavone@retrodev.com>
parents:
2077
diff
changeset
|
213 goto draw; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 case PIXEL1: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 cd->graphics_pixels[1] = get_src_pixel(cd); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 cd->graphics_cycle += 2*4; |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
220 if ((cd->graphics_dst_x & 3) == 2 || (cd->graphics_dst_x + 2 == cd->gate_array[GA_IMAGE_BUFFER_HDOTS] + (cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7))) { |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 cd->graphics_step = DRAW; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 CHECK_ONLY; |
2092
8665d8da0e1c
Fix infinite loop in Sega CD graphics coprocessor code
Michael Pavone <pavone@retrodev.com>
parents:
2077
diff
changeset
|
223 goto draw; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 case PIXEL2: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 cd->graphics_pixels[2] = get_src_pixel(cd); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 cd->graphics_cycle += 2*4; |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
230 if ((cd->graphics_dst_x & 3) == 1 || (cd->graphics_dst_x + 3 == cd->gate_array[GA_IMAGE_BUFFER_HDOTS] + (cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7))) { |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 cd->graphics_step = DRAW; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 CHECK_ONLY; |
2092
8665d8da0e1c
Fix infinite loop in Sega CD graphics coprocessor code
Michael Pavone <pavone@retrodev.com>
parents:
2077
diff
changeset
|
233 goto draw; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 CHECK_CYCLES; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 case PIXEL3: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 cd->graphics_pixels[3] = get_src_pixel(cd); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 cd->graphics_cycle += 2*4; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 CHECK_CYCLES; |
2092
8665d8da0e1c
Fix infinite loop in Sega CD graphics coprocessor code
Michael Pavone <pavone@retrodev.com>
parents:
2077
diff
changeset
|
241 draw: |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 case DRAW: |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 draw_pixels(cd); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 cd->graphics_cycle += 1*4; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 if (!cd->gate_array[GA_IMAGE_BUFFER_LINES]) { |
2098
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
246 return; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 CHECK_ONLY; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 |
2271
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
253 void scd_toggle_graphics_debug(segacd_context *cd) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
254 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
255 if (cd->graphics_debug_window) { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
256 render_destroy_window(cd->graphics_debug_window); |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
257 cd->graphics_debug_window = 0; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
258 } else { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
259 cd->graphics_debug_window = render_create_window("CD ASIC", 1024, 1024, NULL); |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
260 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
261 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
262 |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
263 static void render_graphics_debug(segacd_context *cd) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
264 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
265 int pitch; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
266 uint32_t *fb = render_get_framebuffer(cd->graphics_debug_window, &pitch); |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
267 uint32_t pixels = (cd->gate_array[GA_STAMP_SIZE] & BIT_SMS) ? 4096 : 256; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
268 uint32_t stamp_size = (cd->gate_array[GA_STAMP_SIZE] & BIT_STS) ? 32 : 16; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
269 uint32_t num_stamps = pixels / stamp_size; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
270 //TODO: fix mask based on SMS and STS |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
271 uint32_t address = (cd->gate_array[GA_STAMP_MAP_BASE] & 0xFFE0) << 1; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
272 genesis_context *gen = cd->genesis; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
273 for (uint32_t stamp_y = 0; stamp_y < num_stamps; stamp_y++) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
274 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
275 uint32_t start_y = stamp_y * stamp_size; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
276 for (uint32_t stamp_x = 0; stamp_x < num_stamps; stamp_x++) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
277 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
278 uint16_t entry = cd->word_ram[address++]; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
279 uint32_t tile_address = (entry & 0x7FF) << 6; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
280 //TODO: flip and rotation |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
281 uint32_t start_x = stamp_x * stamp_size; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
282 if (start_x < 1024 && start_y < 1024) { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
283 for (uint32_t tile_x = start_x; tile_x < start_x + stamp_size; tile_x+=8) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
284 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
285 for (uint32_t y = start_y; y < start_y + stamp_size; y++) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
286 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
287 uint32_t *line = fb + y * pitch / sizeof(uint32_t); |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
288 for (uint32_t x = tile_x; x < tile_x + 8; x += 4) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
289 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
290 |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
291 uint16_t word = cd->word_ram[tile_address++]; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
292 uint16_t pixels[4] = { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
293 word >> 12, |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
294 word >> 8 & 0xF, |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
295 word >> 4 & 0xF, |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
296 word & 0xF |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
297 }; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
298 for (uint32_t i = 0; i < 4; i++) |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
299 { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
300 line[x + i] = gen->vdp->colors[pixels[i]]; |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
301 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
302 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
303 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
304 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
305 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
306 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
307 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
308 render_framebuffer_updated(cd->graphics_debug_window, 1024); |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
309 } |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
310 |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 void cd_graphics_run(segacd_context *cd, uint32_t cycle) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 while (cd->graphics_cycle < cycle) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 if (cd->gate_array[GA_STAMP_SIZE] & BIT_GRON) { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 do_graphics(cd, cycle); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 //end calculation and actual emulated execution time probably don't 100% line up yet |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 //deal with that here for now |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 for(; cd->graphics_cycle < cycle; cd->graphics_cycle += 4) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 if (cd->graphics_cycle >= cd->graphics_int_cycle) { |
2098
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
323 printf("graphics end %u\n", cd->graphics_cycle); |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 cd->gate_array[GA_STAMP_SIZE] &= ~BIT_GRON; |
2271
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
325 |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
326 if (cd->graphics_debug_window) { |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
327 render_graphics_debug(cd); |
3ef80963c2a7
Fix stamp address mask and add WIP CD graphics debug view
Michael Pavone <pavone@retrodev.com>
parents:
2098
diff
changeset
|
328 } |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 break; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 cd->graphics_cycle = cycle; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 void cd_graphics_start(segacd_context *cd) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 if (!(cd->gate_array[GA_STAMP_SIZE] & BIT_GRON)) { |
2077
c3241eff3c3a
Sega CD graphics processor output now looks correct for some operations
Michael Pavone <pavone@retrodev.com>
parents:
2071
diff
changeset
|
339 |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 cd->gate_array[GA_STAMP_SIZE] |= BIT_GRON; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 //Manual scan is bad, but formula appears to be |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 // vsize * (13 + 2 * hoffset + 9 * (hdots + hoffset - 1)) |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 //with an additional 13? cycle setup cost per line |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 uint32_t lines = cd->gate_array[GA_IMAGE_BUFFER_LINES]; |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 uint32_t hdots = cd->gate_array[GA_IMAGE_BUFFER_HDOTS]; |
2416
a1afe26a8ef0
Fix mask for CD graphics destination horizontal offset
Michael Pavone <pavone@retrodev.com>
parents:
2271
diff
changeset
|
346 uint32_t hoffset = cd->gate_array[GA_IMAGE_BUFFER_OFFSET] & 7; |
2098
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
347 uint16_t pm = cd->gate_array[1] >> 3 & 3; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 cd->graphics_int_cycle = cd->graphics_cycle + 4 * lines * (13 + 2 * hoffset + 9 * (hdots + hoffset - 1)); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 cd->graphics_dst_y = cd->gate_array[GA_IMAGE_BUFFER_OFFSET] >> 3; |
2098
da326c32ad8f
Fix some bugs in the Sega CD graphics coprocessor
Michael Pavone <pavone@retrodev.com>
parents:
2092
diff
changeset
|
350 printf("graphics start @ %u, %u lines, %u hdots, pm = %u, hoff = %u, voff = %u, addr = %X\n", cd->graphics_cycle, lines, hdots, pm, hoffset, cd->graphics_dst_y, cd->gate_array[GA_IMAGE_BUFFER_START]); |
2077
c3241eff3c3a
Sega CD graphics processor output now looks correct for some operations
Michael Pavone <pavone@retrodev.com>
parents:
2071
diff
changeset
|
351 cd->graphics_step = FETCH_X; |
2069
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 } else { |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 printf("graphics start ignored @ %u\n", cd->graphics_cycle); |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 } |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 |
8e51c0c3f2e3
Initial attempt at implementing the Sega CD graphics hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 } |