Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <new>
00047
00048 #define NEW_IMAGE_VAR
00049 #include <vcrt.h>
00050 #include <macros.h>
00051 #include <sysvar.h>
00052
00053
00054 #include <algorithm>
00055
00056 #include <Helpers/helpers.h>
00057 #include <Image/ByteImage.h>
00058
00059 #include "VCDisplay.h"
00060
00061
00062
00063
00064
00065
00066
00067 inline void wait_for_next_frame()
00068 {
00069 int res;
00070
00071 while ( (res=wait(DISPLAY_EVT, 1000))==2)
00072 {
00073 printf("res: %d\n", res);
00074 }
00075 printf("res: %d\n", res);
00076 }
00077
00078
00079
00080
00081
00082
00083 CVCDisplay::CVCDisplay(bool doubleBuffer, bool show_overlay): m_width(DispGetColumns), m_height(DispGetRows), m_pitch(DispGetPitch), m_doubleBuffer(doubleBuffer)
00084 {
00085
00086 m_allocated_buffer = DRAMDisplayMalloc();
00087
00088 m_display_front = (U8*)((m_allocated_buffer+1023)&(~1023));
00089
00090 std::fill_n(m_display_front, m_height*m_pitch, 128);
00091
00092 if (m_doubleBuffer) {
00093
00094 m_allocated_backbuffer = DRAMDisplayMalloc();
00095
00096 m_display_back = (U8*)((m_allocated_backbuffer+1023)&(~1023));
00097
00098 std::fill_n( m_display_back, m_height*m_pitch, 128);
00099 }
00100 else {
00101 m_allocated_backbuffer = NULL;
00102 m_display_back = NULL;
00103 }
00104
00105 make_current();
00106
00107 if (show_overlay) {
00108 enable_overlay();
00109 std::fill_n( (unsigned char*)OvlGetPhysPage, OvlGetRows*OvlGetPitch, 0);
00110 }
00111 else {
00112 disable_overlay();
00113 }
00114
00115
00116 }
00117
00118 CVCDisplay::~CVCDisplay()
00119 {
00120
00121 restore_default();
00122
00123
00124 DRAMByteFree(m_allocated_buffer);
00125
00126 if (m_doubleBuffer) {
00127 DRAMByteFree(m_allocated_backbuffer);
00128 }
00129
00130 disable_overlay();
00131 }
00132
00133
00134
00135
00136
00137
00138 void CVCDisplay::make_current() const
00139 {
00140
00141 ScrSetDispPage((int)m_display_front);
00142 display_update(UPDATE_DISP);
00143 }
00144
00145 void CVCDisplay::restore_default() const
00146 {
00147
00148 ScrSetDispPage(ScrGetCaptPage);
00149 display_update(UPDATE_DISP);
00150 }
00151
00152
00153
00154 void CVCDisplay::enable_overlay() const
00155 {
00156 setvar(OVLY_ACTIVE,1);
00157 sleep_ms(500);
00158 }
00159
00160
00161 void CVCDisplay::disable_overlay() const
00162 {
00163 setvar(OVLY_ACTIVE,0);
00164 sleep_ms(500);
00165 }
00166
00167 void CVCDisplay::show(const CByteImage* image)
00168 {
00169 if (m_doubleBuffer) {
00170 std::swap(m_display_front, m_display_back);
00171 }
00172
00173 const unsigned char* restrict img_pixels = image->pixels;
00174 unsigned char* restrict disp_pixels = m_display_front;
00175
00176 int h = std::min(m_height, image->height);
00177 int w = std::min(m_width, image->width);
00178
00179
00180 for (int row=0; row<h; row++) {
00181
00182
00183
00184 std::copy(img_pixels, img_pixels+w, disp_pixels);
00185
00186
00187 img_pixels += image->width;
00188 disp_pixels += m_pitch;
00189 }
00190
00191
00192 ScrSetDispPage((int)m_display_front);
00193 display_update(UPDATE_DISP);
00194
00195
00196 }
00197
00198 void CVCDisplay::overlay(const CByteImage *image)
00199 {
00200 const unsigned char* restrict img_pixels = image->pixels;
00201 unsigned char* restrict ovl_pixels = (unsigned char*)OvlGetPhysPage;
00202
00203
00204 int h = std::min(OvlGetRows, image->height);
00205 int w = std::min(OvlGetColumns, image->width);
00206 int ovl_pitch = OvlGetPitch;
00207
00208
00209 for (int row=0; row<h; row++) {
00210 std::copy(img_pixels, img_pixels+w, ovl_pixels);
00211
00212 img_pixels += image->width;
00213 ovl_pixels += ovl_pitch;
00214 }
00215 }
asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Thu Jun 6 2019 21:46:58