Comments (20)
UPDATE: 2019-07-25. Own bug fixed and added much more for getting closer to the ANSI CSI implementation and for having functionality in own project.
I enhanced and fixed some bugs in the current debugScreen implementation.
Also checked all samples to compile cleanly and correctly use CSI sequences.
Maybe the maintainers can consider accpeting these changes for the Vita SDK.
File: Update in post #50 (comment)
debugScreen
- Splitted code and shared definitions into .c and .h file, so it can be used in bigger projects with multiple source files.
C++ projects still need to include the code once(!) into any source file (e.g. main.cpp), for this define DEBUG_SCREEN_CODE_INCLUDE before including the debugScreen header file.
Added custom header file to avoid people messing up the implementation in their projects. - Fixed CSI 0J command. Enhanced sample debugscreen cases to show the issue.
- Added documentation about CSI commands at top and comments in C functions.
- Implemented ANSI/VTERM/GREYSCALE colors via lookup table for correct colors.
- Implemented color state machine to comply better with ECMA-48 / ISO/IEC 6429:1992 and Graphic Rendition Combination Mode (GRCM) "Cumulative".
- Added CSI 22m. Set standard intensity ("normal" color). Accomplishes CSI 1m and 2m.
- Added CSI 7m and 27m. Enable/disable FG/BG inversion.
- Support 16 storage slots for CSI s and u.
- Enhanced bitmap routines to work also with not byte-aligned glyphs.
- Enhanced HTML bitmap editor to work also with not byte-aligned glyphs.
- Draw dummy glyph (dotted line in the middle) in correct font size for not available glyphs.
- Added function to get a copy of current color state.
- Added functions to get/set pixel coordinates for custom save storages and custom positioning.
- Added functions to get/set font.
- Added function to scale a font by 2.
- Sanitized macro usage.
- Fixed typos.
- Extended sample "debugscreen" to test more cases and demonstrate new functions:
- used different background colors to better show CSI J and K commands
- added font scaling
- added inversion on/off via CSI 7m and CSI 27m
- show "dark" white on "bright" black
- added missing glyph
- show all colors CSI 30-37/40-47/90-97/100-107 with their RGB code
- Tested nearly all samples, except for network samples.
Samples in C
- Added "../common/debugScreen.c" in CMakeLists.txt to the project executables:
- audio
- ctrl
- debug_print
- debugscreen
- hello_world
- microphone
- motion
- net_http
- net_http_bsd
- power
- rtc
- socket_ping
- touch
Samples in C++
- Defined DEBUG_SCREEN_CODE_INCLUDE in main.cpp
- net_libcurl
- soloud
Sample camera
- Added missing include <psp2/kernel/processmgr.h> for sceKernelExitProcess().
Sample microphone
- Added missing include <string.h> for memset() and memcpy().
- Changed direct access to coordX/Y to CSI sequences.
Sample net_http_bsd
- Changed direct access to font to new functions.
Sample power
- Added missing include <stdio.h> for FILE, fopen(), fclose().
- Added missing include <string.h> for memset().
0J bug with old implementation
New debugscreen sample
from samples.
Don't want to outsmart or avoid the optimizer of the compiler (via pragmas, flags, etc.) as I never would assume that I'm smarter than those guys developing compilers.
Just doing calculations when necessary and where appropiate (e.g. either before or inside a loop).
Always try to keep code maintainable/clean, sanitized, straight forward and re-usable.
Just read all available docs for CSI sequences and hope to get it done the next days.
from samples.
@yne net_http_bsd
is looking good.
from samples.
That's not the only issue with that sample in particular. It refers to an old vitasdk version. The sample itself should be updated.
from samples.
@Rinnegatamante Thanks for the insight.
I investigated further and recognized that psvDebugScreenClear()
was transformed to the macro CLEARSCRN
. The code of the macro is much slower than the old one for the full screen, where lines and columns do not matter (complete screen vs. rectangular block).
Additionally I wonder why the debug screen code is inside a header file and has several static definitions.
Currently adapting the old psvDebugScreenClear()
function, plus splitting debug screen code and defines into separate code and header files.
from samples.
Adapted psvDebugScreenClear()
to current state of debug screen code.
Put debug screen code into a .c file while still keeping the possibility to include it.
Fixed typos, sanitized some macros, prepared macro for font scaling.
All debugScreen*.(h|c)
files are still in common folder.
Just have to list ../common/debugScreen.c
in add_executable()
.
For other projects all debugScreen*.c
files can also be put into a src
folder and all debugScreen*.h
files into an inc(lude|)
folder.
common_debugScreen_20190718.zip
Next will be to adopt the font scaler to it. Like debug_put_char_32()
of https://github.com/TheOfficialFloW/h-encore/blob/master/bootstrap/scr_printf.c
from samples.
The debugScreen.h
is ANSI compatible. So please stop using all those psvDebugScreenSet{F,B}gColor
/ psvDebugScreenClear
functions and just use escape sequence while calling printf.
See: https://github.com/vitasdk/samples/blob/master/debug_print/src/main.c
@Rinnegatamante Yeah I was probably waiting for some feedback and eventually lost track of time and simply moved to another project.
@windsurfer1122 psvDebugScreen
was never meant to be efficient
Sure we could use the DMA to clear the screen, or the GMX to draw the glyphs faster. But that's not the goal of this library.
So you want to switch to a bigger/smaller font ? there's a sample for that.
from samples.
@yne Thanks for the explanation. Never had to deal with CSI sequences back in my C days. Will re-adapt.
from samples.
Nice job, it's always nice to see some unification.
What was the issue from having a single self-exclusive .h file ?
The power sample is definitely strange:
- the fopen shall not succeed to create a new file unless
w+
- the created
fd
is unused
from samples.
My private project will have 2 or 3 different source files (*.c) and all of them will create some debugScreen output. If the old "debugScreen.h" is included in all 3 files, I will have duplicate code in my .o files and/or linker issues.
Side note:
When checking my own bug I also found out that the color creation for CSI m is a little bit off:
- CSI 2m is actually "dark" color (faint/decreased intensity) and not "normal" color/intensity
- CSI 22m is "normal" color/intensity
- CSI 30-37/40-47/90-97/100-107m do not fit to CSI 1/2m implementation
- Naming is sometimes wrongly RGB although internally it is BGR.
Open points: - Check official CSI documentation (see [1])
- CSI 1/2/22m seem to be flags rather than just an immediate color change, e.g. CSI 1;31m should be identical to CSI 31;1m?
- Check CSI 38/48;5;(n)m implementation
So I'm currently fixing these, also implementing CSI 7m for "invert"/"reverse video" and optimze code on the way (guideline: always code like there is no compiler optimization).
My sample "debugscreen" is becoming heavily colorful :)
Will need some more days due to time constrains.
[1] https://www.ecma-international.org/publications/standards/Ecma-048.htm
from samples.
I will have duplicate code in my .o files and/or linker issues.
Have you tried to change psvDebugScreen{Init,Puts,Printf}
to static
?
In my tests it resolve the linking issue, and the code is not duplicated either, and it's still easy to include in small project (like all the vita samples).
guideline: always code like there is no compiler optimization
Did you mean
Trying to outsmart a compiler defeats much of the purpose of using one -- Kernighan
?
So I'm currently fixing these, also implementing [...]
Let's hope those features and hand-crafted optimization won't add more bugs and complexity than the features they add
from samples.
Updated earlier comment/post #50 (comment) with updated implementation. Tested quite a lot and should be a solid implementation. Should be final.
Ready for review.
from samples.
You shall at least check net_http_bsd
sample because it printf the result of http://rate.sx/ and http://wttr.in/ wich rely on those CSI codes.
from samples.
@windsurfer1122 nice :)
Any update about the static
suggestion ?
If it's working, your PR shall be more simple (no #include
or CMake
changes)
from samples.
Hiding internal functions via static
is ok, but for shared functions this would be awkward.
The static
suggestion would make the code local to the source (and its related binary object), therefore for each source file of a project the same code would be compiled and included into the final binary.
Will check if the current gcc is intelligent enough and recognizes the duplicate binary result. But that will be on sunday.
The only reason I found for including the code as it was before, was for C++, and that could be handled with a simple #define.
The changes to the CPP source with #define
and to the CMakeLists.txt
are very minor from my point of view. Even for unexperienced C/C++ coders.
Is this still a pain in your stomache?
from samples.
Is this still a pain in your stomache?
Nah I'm fine, I was just curious if the static
version was also working in your situation.
The .c
+.h
is the most common practice, (even if It's not my cup of tea anymore, than you Bellard).
I'm okay to have it in c+h style, don't worry :).
from samples.
Compromise:
- Use
#define DEBUG_SCREEN_CODE_INCLUDE
in debugScreen_custom.h (gets rid ofCMakeLists.txt
changes) - Leave the
#define
in C++, as it is mandatory for them.
File: sdk-common-debugscreen-fixes-enhancements_20190726_1459.zip
And thanks for your reviews and discussion.
from samples.
My first pull request. Hope this is done correctly.
#51
from samples.
Updated pull request. Corrected header file for C++, so even less changes are needed in the C++ samples to the source code.
from samples.
Added via ded5780
from samples.
Related Issues (18)
- Needs more samples
- Need to rename lSceKernel_stub to lSceLibKernel_stub in the samples HOT 1
- CMake everything
- Create a sample plugin
- SDL2 Github Link 404s HOT 4
- cmake in samples don't add images into vpk HOT 6
- Sample 3 Net_http cant write file because it is unsafe HOT 4
- can you add a sample about loading and playing audio files? HOT 7
- offline api docs HOT 3
- Can't make Hello World on latest commit HOT 7
- undefiend reference errors when compiling hello_cpp_world HOT 4
- error with SDL2/SDL_mixer HOT 1
- Can't compile prx_simple - unknown type name 'SceDisplayFrameBuf' HOT 8
- error with SDL2/SDL2_ttf HOT 1
- Issue when building with cmake HOT 5
- CMake error on SDL when trying to compile on linux HOT 2
- What happened to the libgxm samples? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from samples.