Mercurial > repos > blastem
comparison oscilloscope.c @ 2685:da2e06c42d16
Add a compile-time flag to use RGB565 instead of ABGR/ARGB
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 30 Mar 2025 00:06:53 -0700 |
parents | d30ea441b92e |
children |
comparison
equal
deleted
inserted
replaced
2684:c649bcc18487 | 2685:da2e06c42d16 |
---|---|
54 } | 54 } |
55 } | 55 } |
56 void scope_render(oscilloscope *scope) | 56 void scope_render(oscilloscope *scope) |
57 { | 57 { |
58 int pitch; | 58 int pitch; |
59 uint32_t *fb = render_get_framebuffer(scope->window, &pitch); | 59 pixel_t *fb = render_get_framebuffer(scope->window, &pitch); |
60 memset(fb, 0, HEIGHT * pitch); | 60 memset(fb, 0, HEIGHT * pitch); |
61 pitch /= sizeof(uint32_t); | 61 pitch /= sizeof(pixel_t); |
62 int offset = 0; | 62 int offset = 0; |
63 int column_width = WIDTH/3; | 63 int column_width = WIDTH/3; |
64 int width = column_width * 3; | 64 int width = column_width * 3; |
65 int row_height = HEIGHT / ((scope->num_channels + 2) / 3); | 65 int row_height = HEIGHT / ((scope->num_channels + 2) / 3); |
66 float value_scale = (float)row_height / 20000.0f; | 66 float value_scale = (float)row_height / 20000.0f; |
67 uint32_t *cur_line = fb; | 67 pixel_t *cur_line = fb; |
68 pixel_t white = render_map_color(255, 255, 255); | |
68 for (uint8_t i = 0; i < scope->num_channels; i++) | 69 for (uint8_t i = 0; i < scope->num_channels; i++) |
69 { | 70 { |
70 float samples_per_pixel = (float)scope->channels[i].period / (float)(2*column_width); | 71 float samples_per_pixel = (float)scope->channels[i].period / (float)(2*column_width); |
71 uint32_t start = scope->channels[i].last_trigger; | 72 uint32_t start = scope->channels[i].last_trigger; |
72 if (start == INVALID_TRIGGER) { | 73 if (start == INVALID_TRIGGER) { |
94 y += row_height / 2; | 95 y += row_height / 2; |
95 if (last_y >= 0) { | 96 if (last_y >= 0) { |
96 int delta = last_y > y ? -1 : 1; | 97 int delta = last_y > y ? -1 : 1; |
97 while (last_y != y) | 98 while (last_y != y) |
98 { | 99 { |
99 cur_line[last_y * pitch + x ] = 0xFFFFFFFF; | 100 cur_line[last_y * pitch + x ] = white; |
100 last_y += delta; | 101 last_y += delta; |
101 } | 102 } |
102 } else { | 103 } else { |
103 last_y = y; | 104 last_y = y; |
104 } | 105 } |
105 cur_line[y * pitch + x ] = 0xFFFFFFFF; | 106 cur_line[y * pitch + x ] = white; |
106 cur_sample += samples_per_pixel; | 107 cur_sample += samples_per_pixel; |
107 if (cur_sample + 0.5f >= scope->channels[i].period) { | 108 if (cur_sample + 0.5f >= scope->channels[i].period) { |
108 cur_sample -= scope->channels[i].period; | 109 cur_sample -= scope->channels[i].period; |
109 } | 110 } |
110 } | 111 } |