Jump to content
Sign in to follow this  
Nop90

Experimenting with colors changing every HBL

Recommended Posts

Today wanted to play a little with the HBL interrupt to display images with more than 16 fixed colors, so wrote  a little script (using imagemagick) that from a generic 160x102 png first downscales the colors to 256, than  creates a set of images (one for every line), everyone with only 16 colors. The 102 images are rendered on the screen and the corresponding platettes are changed at every HBL.

 

Nothing new with this way to show more than 16 colors, only I'm not happy if I don't code things by myself.

 

I was especting to have to apply some postprocessing to optimize the palettes, but surprisingly the images are very good only with the authomatic processing.

 

Here are the first three image I converted.

 

Attached there is the source code too. It's only a fast POC so forgive me the bad coding. I know that I don't need to use tgi to draw the image since I have to disable it to change colors and I also know that I don't need to use all that memory to setup data in memory but it's better to create offline two big arrays (one for image daa  and one for the palettes), but I'm lazy 😅

 

What about it? I'm going to optimize this tool and use it to show nice colored splash screens in my next games.

 

bigtree__colorpic.lnx nebula_colorpic.lnx skyline_colorpic.lnx hicol.zip

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

will not work. if you use HBL interrupt you dont have the time to set the full palette.

you either have to poll the register or set up another timer which interrupts before the end of line and then poll the register.

 

Edited by sage

Share this post


Link to post
Share on other sites

I described here how I did it for assembloids:

 

The Bastion demo also features it including a scroller above the image.

Share this post


Link to post
Share on other sites

I see, it only works on emulator, but not on real lynx, anyway it's a starting point for my experimenting.

 

I'll try reducing the colors per line and optimixing the palette leaving some fixed colors.

 

Do you yow how many clocks last the HBL for the 3 refresh rates?

Share this post


Link to post
Share on other sites

At 50hz my lynx 2 seems can do the job (try the attached rom), at 60Hz i can write only 29 bytes of the palette out of 32: at 30 bytes starts the flickering.

 

So seems it's possible. Could soemone try it on a upgraded LCD? I have only unmoded lynx for the moment.

skylyne_50hz.lnx

Share this post


Link to post
Share on other sites

You can do it at 60Hz as well. I think HBL is not best suited since you lose the time you would otherwise have in Vblank. But it should work as well in HBL 🙂

The tree is nice :) In general you'd want motives with vertical gradients to show off the colors.

Share this post


Link to post
Share on other sites
1 hour ago, Nop90 said:

I see, it only works on emulator, but not on real lynx, anyway it's a starting point for my experimenting.

I'll try reducing the colors per line and optimixing the palette leaving some fixed colors.

I think i left some code in the public version here. But I was not satisfied because i left too many relicts in the picture.

 

http://lynxdev.atari.org/BmpConvert.exe

Share this post


Link to post
Share on other sites
17 minutes ago, enthusi said:

You can do it at 60Hz as well. I think HBL is not best suited since you lose the time you would otherwise have in Vblank. But it should work as well in HBL 🙂

The tree is nice :) In general you'd want motives with vertical gradients to show off the colors.

ONe question: how much is the music distorted if you use this?

Share this post


Link to post
Share on other sites

You can check in Bastion 🙂

In fact I didn't use 102 lines when music is running.

Share this post


Link to post
Share on other sites

How many clock cycles is the horizontal blank (if any)?

 

And the is the Vblank only the first 3 horizontal lines not displayed on the LCD?

Edited by Nop90

Share this post


Link to post
Share on other sites

@Nop90

I've tried to actually measure it by placing varying number of NOPs in the HBI routine.

Please correct me if I'm wrong.

First of all CPU clocks are no good unit of measure when dealing with tracing the beam as one clock cycle can take 4 or 5 system clock ticks. The whole line with 60 Hz refresh rate takes 159 μs = 2544 ticks. According to my measurements it seems that the first color change visible on screen is after about 30 μs = 480 ticks. It's slightly more than 100 CPU cycles.

I'm attaching output of my test program. The white pattern is binary encoded VCOUNT_COUNT. Green pattern is a sequence of  sta GREEN0 / stz GREEN0 delayed for about ( 26 + 80 + VCOUNT_COUNT ) * 4 + 11 * 5 system ticks including interrupt (+-4 ticks ).

 

VBlank is for 3 lines, but keep in mind that two first visible lines are for some reason unstable just as if the HBI launched in various "moments" with few pixels of variance.

 

c0000.png

Edited by laoo

Share this post


Link to post
Share on other sites

thank you @laoo you helped me a lot.

 

I was giving up in the project of displaying a general (i.e. not optimized at design time) 256 colors image on the screen of a real lynx. My code was working on the emulator but on real lynx I had problems in the first third of the screen.

 

With your timing as reference I reorganized my code and now it works fine on real lynx.

 

Here is an image (with attached the lnx rom if someone want test himself on a real lynx) of a nice splash screen that @marss made for 4ttude.

 

4ttude.png.dd32e3cda7a1bd02aaa274ca82ca4f7d.png

 

I'm going to update the 4ttude rom with this tonight (I released a new version of 4ttude some hours ago, but without this splash sceen, because I was starting to think it was an impossible task to display it correctly).

image.lnx

  • Like 2

Share this post


Link to post
Share on other sites

Nice. This mode has quite some potential in general!

From the gfx used in the Bastion demo:

 

test4_lynx.png

Edited by enthusi

Share this post


Link to post
Share on other sites

For the moment I want to keep my code private, but if someone wants I can give enough details on how I accomplished this to make it easily replicable.

 

Obviusly the asm part can be decompiled from the rom, but there is a big part of automatic image preprocesssing done with perl scripts and the convert tool from imagemagick.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...