 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
cosmito
Joined: 04 Mar 2007 Posts: 314 Location: Portugal
|
Posted: Mon Sep 24, 2007 7:31 am Post subject: Glitches in gsKit font display |
|
|
I've been trying a bit the font support of gsKit and I modicied the gsKit\examples\fontm example so that it scrolls a bunch of text lines up and down the screen.
| Code: | #include "gsKit.h"
#include "dmaKit.h"
#include "malloc.h"
int main(void)
{
u64 White, Black, BlackFont, WhiteFont, BlueTrans, RedTrans, GreenTrans, WhiteTrans;
GSGLOBAL *gsGlobal = gsKit_init_global(GS_MODE_NTSC);
GSTEXTURE test;
int Y = -400;
int sig = 1;
GSFONT *gsFont = gsKit_init_font(GSKIT_FTYPE_FONTM, NULL);
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
// Initialize the DMAC
dmaKit_chan_init(DMA_CHANNEL_GIF);
dmaKit_chan_init(DMA_CHANNEL_FROMSPR);
dmaKit_chan_init(DMA_CHANNEL_TOSPR);
Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00);
White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00);
WhiteFont = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00);
BlackFont = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00);
u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00);
BlueTrans = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x40,0x00);
RedTrans = GS_SETREG_RGBAQ(0xFF,0x00,0x00,0x60,0x00);
GreenTrans = GS_SETREG_RGBAQ(0x00,0xFF,0x00,0x50,0x00);
WhiteTrans = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x50,0x00);
gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
gsKit_init_screen(gsGlobal);
gsKit_font_upload(gsGlobal, gsFont);
gsFont->FontM_Spacing = 0.95f;
gsKit_texture_bmp(gsGlobal, &test, "host:test.bmp");
test.Filter = GS_FILTER_LINEAR;
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
while(1)
{
gsKit_clear(gsGlobal, Black);
gsKit_font_print_scaled(gsGlobal, gsFont, 50, Y, 3, 0.85f, TexCol,
"1: ABCDEFGHIJKLM\n"
"2: NOPQRSTUVWXYZ\n"
"3: abcdefghijklm\n"
"4: nopqrstuvwxyz\n"
"5: 1234567890,./`\n"
"1: ABCDEFGHIJKLM\n"
"2: NOPQRSTUVWXYZ\n"
"3: abcdefghijklm\n"
"4: nopqrstuvwxyz\n"
"5: 1234567890,./`\n"
"1: ABCDEFGHIJKLM\n"
"2: NOPQRSTUVWXYZ\n"
"3: abcdefghijklm\n"
"4: nopqrstuvwxyz\n"
"5: 1234567890,./`\n"
"6: ~!@#$%^&*()_<>\n");
Y = Y + (1 * sig);
if (Y>600)
{
sig = -1;
Y = 600;
}
if (Y<-400)
{
sig = 1;
Y = -400;
}
gsKit_sync_flip(gsGlobal);
gsKit_queue_exec(gsGlobal);
}
return 0;
}
|
I noticed some glitches in the '1' of the first line when the text block reaches the lowest half of the screen... If we reduce the number of text lines to the first 3, it seems to go away.
Maybe a timing issue of gsKit font rendering? |
|
| Back to top |
|
 |
Lukasz

Joined: 19 Jan 2004 Posts: 248 Location: Denmark
|
Posted: Mon Sep 24, 2007 8:43 am Post subject: |
|
|
My guess would be that you are rendering with invalid coordinates. Make sure that XYOFFSET + your X,Y coords dont exceed 4096 and get below 0. You can read more about this in the GS Manual, look for "Coordinate Systems".
Timing could also be an issue, but as long as you are waiting for FINISH, there shouldn't be a problem. _________________ Lukasz.dk |
|
| Back to top |
|
 |
cosmito
Joined: 04 Mar 2007 Posts: 314 Location: Portugal
|
Posted: Tue Sep 25, 2007 8:15 am Post subject: |
|
|
| Lukasz wrote: | | My guess would be that you are rendering with invalid coordinates. Make sure that XYOFFSET + your X,Y coords dont exceed 4096 and get below 0. You can read more about this in the GS Manual, look for "Coordinate Systems". |
Yes in fact you're right and playing on the right side. I should read the docs but I went straight experimenting with it, hoping support for negative coords. Thanks for the tip on the chapter title.
But if negative could cause problems that would invalidate my approach to get a simple scrolling method...
Basically you'll only need to keep a text block long enough to cover some few lines above and bellow the visible area of the screen, not the whole text at once. When the text block moved N pixels (being N the height of the font) the text string block would be replaced by a new with the next line and the Y coord would go back N pixels... Well, trivial I guess :) |
|
| Back to top |
|
 |
cosmito
Joined: 04 Mar 2007 Posts: 314 Location: Portugal
|
Posted: Wed Oct 31, 2007 9:39 am Post subject: a complete example |
|
|
Finally I had the time to pack an example of text scrolling I made based on the fontm gsKit example.
Like I suspected, the use of negative coordinates is not responsable for the occasional glitches (I made a version that uses only positive text positioning)
If you want to try the scroll example, go to :
http://www.esnips.com/web/ps2-homebrew/
and download the fontm_scroll.zip.
The glitches seems to occurs on some characters depending on the line length... Change the text and with luck you get a perfect scrolling. |
|
| Back to top |
|
 |
radad
Joined: 19 May 2004 Posts: 246 Location: Melbourne, Australia
|
Posted: Wed Oct 31, 2007 12:56 pm Post subject: |
|
|
| I have come across some text glitches also. What I found was that there was a limited number of buffers for blocks of text information loaded to the GS. I am going from memory here but I think the default was two blocks. Changing this to four blocks made the glitches less common but they didn't completely go away. The problem is that the more blocks you use for font texture information leaves less room for other textures. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|