Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Quick-and-dirty P.O.C. changing palettes between scanlines for extra sprite colors

Reply to topic
Author Message
  • Joined: 25 Feb 2006
  • Posts: 874
  • Location: Belo Horizonte, MG, Brazil
Reply with quote
Quick-and-dirty P.O.C. changing palettes between scanlines for extra sprite colors
Post Posted: Fri Mar 04, 2022 11:57 pm
Last edited by haroldoop on Sat Mar 05, 2022 9:32 am; edited 1 time in total
Hello again;

This is a quick-and-dirty test to try to get extra sprite colors by changing palettes between scanlines.

I probably won't use it for anything, but here it is, in case somebody is interested. :P

Github link: https://github.com/haroldo-ok/rpg-battle-poc
rpg_battle.png (1.62 KB)
Screenshot
rpg_battle.png
rpg_battle-0.1.sms.zip (3.97 KB)
The ROM for version 0.1
rpg-battle-poc-0.1.src.zip (22.16 KB)
Source code for version 0.1

  View user's profile Send private message Visit poster's website
  • Joined: 06 Aug 2015
  • Posts: 149
Reply with quote
Post Posted: Sat Mar 05, 2022 1:17 am
haroldoop wrote
Hello again;

This is a quick-and-dirty test to try to get extra sprite colors by changing palettes between scanlines.

I probably won't use it for anything, but here it is, in case somebody is interested. :P


Fera!
  View user's profile Send private message
  • Joined: 05 Mar 2022
  • Posts: 129
  • Location: Seabrook, New Hampshire
Reply with quote
Post Posted: Sat Mar 05, 2022 4:43 am
haroldoop wrote
Hello again;

This is a quick-and-dirty test to try to get extra sprite colors by changing palettes between scanlines.

I probably won't use it for anything, but here it is, in case somebody is interested. :P


How many Z80 cycles are there between scanlines. For some reason, when I heard that you could move the scanline right or left during this short time gap, I'd assumed that couldn't also color cycle nor do anything else useful at the same time.

I've been coming up with ideas for improving color, but I didn't know if there was enough time between lines.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Sat Mar 05, 2022 7:35 am
Horizontal interrupts are quite inefficient, they fire early (or is it late?) so you have to waste a few cycles to align to the offscreen area, and then I think you only have time to update two colours per line without causing cram dots to be visible in the active area.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Feb 2006
  • Posts: 874
  • Location: Belo Horizonte, MG, Brazil
Reply with quote
Post Posted: Sat Mar 05, 2022 11:13 am
Maxim wrote
Horizontal interrupts are quite inefficient, they fire early (or is it late?) so you have to waste a few cycles to align to the offscreen area, and then I think you only have time to update two colours per line without causing cram dots to be visible in the active area.


So, in theory, with some really tight timing, someone cold change all of the 16 sprite colors in a spread of 8 scanlines with no visual artifacts?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Sat Mar 05, 2022 6:48 pm
I think so, yes. It’s not very practical though as there sprites have to avoid each other vertically :) but could be useful for a status area or split screen game.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Mar 2022
  • Posts: 129
  • Location: Seabrook, New Hampshire
Reply with quote
Post Posted: Sat Mar 05, 2022 10:14 pm
Quote
So, in theory, with some really tight timing, someone could change all of the 16 sprite colors in a spread of 8 scanlines with no visual artifacts?


It's good to change the color palette, and that's occasionally needed (especially for color swapping to get flowing waterfalls, lava, animation, etc.), but the more important one is moving that horizontal line at a different rate than its contemporaries, giving us that all important parallax effect.

I'd also thought of using that interlude to update the audio, which can be done at 15.7KHz if done at the end of every scanline. That doesn't really need an interrupt sent to the processor, but it seemed handy, if the overhead of a line interrupt is to be accepted anyway.

We have only 60,000 cycles per frame and just 310 Z80A cycles per line, IIRC. Accounting for the line interrupt overhead, that only allows a couple of subroutines running about 60-100 instructions per line, depending on how the code is written.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!