Blanking the display for one (or more) scanlines only

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Blanking the display for one (or more) scanlines only

Post by BigEvilCorporation » Sun Apr 24, 2016 11:46 am

Hi!

I'm trying to achieve a "letterbox" style mode for cutscenes, creating black bars at the top and bottom of the screen. Modifying the tiles isn't a viable option without some considerable changes to my codebase, and it would use too many sprites.

I've tried blanking the display by modifying VDP reg 2 during HINT, which seems to give the desired effect for sprites but not for scroll planes.

Has anyone experimented with changing VDP regs inside HINT, and could share their findings?
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Blanking the display for one (or more) scanlines only

Post by Sik » Sun Apr 24, 2016 12:48 pm

VDP reg 2 ($82xx) is the scroll A plane address...

As far as I'm aware you just have to toggle the display bit in reg 1 ($8134 disables display while keeping vblank IRQ and DMA turned on, $8174 turns it back on). That should affect everything, just beware that if you do it mid-scanline that it will blank the line halfway (with a granurality of 16 pixels - note to emulator authors: do it too early and Overdrive glitches).

If you only got it to work for sprites then you did something really wrong =P
Sik is pronounced as "seek", not as "sick".

BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Re: Blanking the display for one (or more) scanlines only

Post by BigEvilCorporation » Sun Apr 24, 2016 4:10 pm

Sik wrote:If you only got it to work for sprites then you did something really wrong =P
Damn. Well, my code is simple enough:

Code: Select all

HBlankInterrupt:
	move.l d0, -(sp)

	move.w (hline_counter), d0
	andi.w #0x1, d0
	cmp.w  #0x1, d0
	beq    @ScreenOff
	
	move.w #0x8174, vdp_control
	
	bra     @EndLetterbox
	
	@ScreenOff:
	
	move.w #0x8134, vdp_control
	
	@EndLetterbox:
	
	move.l (sp)+, d0
	
	addi.w #0x1, hline_counter
	rte
Which produces:

Image

but the original scene looks like:

Image
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Blanking the display for one (or more) scanlines only

Post by Sik » Sun Apr 24, 2016 4:52 pm

You aren't trying to write to the scroll planes while the hblanks are happening, right? Because setting a register will unset the current address.

By the way, you can remove the CMP, it's redundant. In fact, it the subroutine is in RAM (convenient when you can have multiple hblank subroutines in the program) you probably could do this (where HBlank points to the subroutine address in RAM):

Code: Select all

    move.w  #$8134, ($C00004)
    bchg.b  #6, (HBlank+3)
    rte
EDIT: but wait, is the scanlines effect the one you're trying to do? =/
Sik is pronounced as "seek", not as "sick".

BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Re: Blanking the display for one (or more) scanlines only

Post by BigEvilCorporation » Sun Apr 24, 2016 5:02 pm

Sik wrote:You aren't trying to write to the scroll planes while the hblanks are happening, right? Because setting a register will unset the current address.
No, I keep the update and render code mutually exclusive, and there is nothing else in my hblank routine.
Sik wrote: By the way, you can remove the CMP, it's redundant.
Yep, something I learned recently and need to go back over the whole codebase optimising it all! Self-modifying code isn't something I've started learning yet, maybe later.
Sik wrote: EDIT: but wait, is the scanlines effect the one you're trying to do? =/
No, this is just a test. Eventually I want to blank the first and last 16 scanlines (maybe animating from 0 to 16).
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

powerofrecall
Very interested
Posts: 237
Joined: Fri Apr 17, 2009 7:35 pm
Location: USA

Re: Blanking the display for one (or more) scanlines only

Post by powerofrecall » Tue Apr 26, 2016 2:46 am

I was thinking you could probably achieve the effect using h-ints to copy palettes at the appropriate times. You start with an all black palette, then when you hit the right scanline, switch to your color palette. Then when you hit the scanline you want on the bottom, switch back to all-black. You'd likely get the ugly CRAM dots here (but maybe it wouldn't be as obvious? They would be black perhaps??). This way you wouldn't even need to worry about masking sprites or constraining them to the viewport.

If there's a hole in this idea I'm curious.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: Blanking the display for one (or more) scanlines only

Post by TmEE co.(TM) » Tue Apr 26, 2016 4:07 am

It is easier to turn off rendering than to start messing with CRAM in the HBL handler, 1 write vs bazillion :P
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: Blanking the display for one (or more) scanlines only

Post by tryphon » Tue Apr 26, 2016 2:45 pm

Sik wrote:

Code: Select all

    move.w  #$8134, ($C00004)
    bchg.b  #6, (HBlank+3)
    rte
:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D
VERY
CLEVER !!!!!

just that :)

Post Reply