Converting png/jpg to KMG - garbled output when pvr updates

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
bogglez
Moderator
Moderator
Posts: 576
Joined: Sun Apr 20, 2014 9:45 am
Has liked: 0
Been liked: 0

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by bogglez » Fri Jul 29, 2016 8:44 am

Looking at the code in your screenshot: Why don't you pass sprite to draw_raster()?
You already looked the sprite up in draw_sprite_raster(), now you repeat this work height times in draw_raster().
Suppose the sprite is number 50 in your sprite sheet and 32 pixels high, then you're doing 50*32=1600 string comparisons every frame when drawing that one sprite.

And you can change the palette by line? I didn't know that. I thought I had tested it in the past and it didn't work. I thought the palette persists through the whole frame?
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
ThePerfectK
DCEmu Freak
DCEmu Freak
Posts: 94
Joined: Thu Apr 27, 2006 10:15 am
Has liked: 6 times
Been liked: 13 times

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by ThePerfectK » Fri Jul 29, 2016 8:53 am

bogglez wrote:Looking at the code in your screenshot: Why don't you pass sprite to draw_raster()?
You already looked the sprite up in draw_sprite_raster(), now you repeat this work height times in draw_raster().
Suppose the sprite is number 50 in your sprite sheet and 32 pixels high, then you're doing 50*32=1600 string comparisons every frame when drawing that one sprite.
it was a dirty test to get it working, I've already cleaned up the code :P
And you can change the palette by line? I didn't know that. I thought I had tested it in the past and it didn't work. I thought the palette persists through the whole frame?
well, I can simulate changing the palette by line in any case. I'm drawing a bunch of thin polygons, and can switch which palette each polygon is drawn with. Part of the reason I wanted 64 16 color palettes instead of 4 256 color palettes was so I could sacrifice half of my palettes to underwater shades. I have my "underwater palette" set at 32 palette entries beyond the original, so if I want to switch between the two I just add 32 to the current palette number.

I'm working on drawing a rolling sin-wave patterned background at the moment, once I get that going, I'll show an example of the water trick I'm doing.
Still Thinking!~~
User avatar
ThePerfectK
DCEmu Freak
DCEmu Freak
Posts: 94
Joined: Thu Apr 27, 2006 10:15 am
Has liked: 6 times
Been liked: 13 times

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by ThePerfectK » Fri Jul 29, 2016 10:46 am

All sorts of effects in this frame lol:

Image

In this case, I have the line scroll going on a transparent foreground texture that is displaying over a sprite that I'm rotating whose palette I've manually set. Next up, I'm going to show that palette swap mimic, maybe I'll package it all together in a small demo people can download. The foreground layer is also tiled in case it's not obvious :D
Still Thinking!~~
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by Chilly Willy » Fri Jul 29, 2016 11:54 am

That's pretty damn slick! Just shows that even without a special 2D coprocessor, you can still do some slick 2D stuff. Just takes more elbow-grease on the part of the programmer. 8-)
User avatar
bogglez
Moderator
Moderator
Posts: 576
Joined: Sun Apr 20, 2014 9:45 am
Has liked: 0
Been liked: 0

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by bogglez » Sun Jul 31, 2016 6:28 am

For shear effects you can just use a simple rectangle and offset the bottom points on the x axis while leaving the texture coordinates alone btw
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
ThePerfectK
DCEmu Freak
DCEmu Freak
Posts: 94
Joined: Thu Apr 27, 2006 10:15 am
Has liked: 6 times
Been liked: 13 times

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by ThePerfectK » Sun Jul 31, 2016 6:38 am

bogglez wrote:For shear effects you can just use a simple rectangle and offset the bottom points on the x axis while leaving the texture coordinates alone btw
That's if I want linescroll to be uniform and every line, however. If I want a variable width line scroll, like the tricks they use in Axelay, I'd have to chop the quad up into several chunks per linescroll.
Still Thinking!~~
User avatar
ThePerfectK
DCEmu Freak
DCEmu Freak
Posts: 94
Joined: Thu Apr 27, 2006 10:15 am
Has liked: 6 times
Been liked: 13 times

Re: Converting png/jpg to KMG - garbled output when pvr upda

Post by ThePerfectK » Thu Aug 18, 2016 4:01 am

Still at it:

Image

My first version of this effect ran at 15 fps. I've got it to a full 60 fps now.

It's going in steps in this picture, but I can make it go as smooth as the original pic, except 4 times as fast :D
Still Thinking!~~
Post Reply