V & H interrupt problem

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

Post Reply
koilazka
Interested
Posts: 30
Joined: Mon Nov 30, 2009 1:51 am

V & H interrupt problem

Post by koilazka » Sat Mar 20, 2010 3:27 pm

This is my first post here, hiya.


Ive been writing a rom and reading reference for a while.
Im pritty used to the VDP now, but i cant seem get the V and H interrupts working.

Code: Select all

video_setup:
		lea	($C00000).l,a0		;// set a0 to vdata
		lea	($C00004).l,a1		;// set a1 to vctrl

		move.w	#$8014,(a1)		;// : mode set #1: [0][0][0][IE1][0][1][M3][0]
		move.w	#$8164,(a1)		;// : mode set #2: [0][DIS][IE0][M1][M2][1][0][0]

		....
After setting the video up, writing patterns to vram...
The program loop moves a sprite from left to right by updating the attribute table.
At the start of the loop i waste some processes.

Code: Select all

scene_ac:
		move.w	#$1000,d0		;// $1000 to d2
scene_ac_aa:
		dbf	d0,scene_ac_aa
at the end it branches back to the start.

Code: Select all

		bra	scene_ac
I added this code to the V & H interrupts, which should disable the display and just show the background. The only way i got it to work, was by using an "rte" at the end of the program loop, then jumping to the beginning from the Main Entrypoint.

Code: Select all

Horizontal:
		nop
		nop
		nop
		move.w	#$8124,(a1)
		rte


Vertical:
		nop
		nop
		nop
		move.w	#$8124,(a1)
		rte
Ive been reading the gen tech bulletins for a few days, everything i try doesnt work :/
In the gen techs, it states the H interrupt may cancel the V interrupt, that had 2 solutions, 1 of them confused the hell outta of me.


Know any reasons why this may happen?.. Tanks in advance :L

Gigasoft
Very interested
Posts: 95
Joined: Fri Jan 01, 2010 2:24 am

Post by Gigasoft » Sat Mar 20, 2010 4:03 pm

Remember to have a move.w #$2300,sr somewhere in your setup code. And to get H interrupts working, you have to set up the line counter initial value (VDP register 10). If you only use it once per frame, you can disable the H interrupt when it's reached. If you use it multiple times in one frame, it's more complicated. I don't recommend depending on the original values of registers in an interrupt handler, since it means you can't use the register for anything else.

koilazka
Interested
Posts: 30
Joined: Mon Nov 30, 2009 1:51 am

Post by koilazka » Sat Mar 20, 2010 9:18 pm

Thanks gigasoft, move.w #$2300,sr worked straight away.
I guess that enables the interrupts with the 68k system byte.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Mar 20, 2010 10:48 pm

You should really read the 68000 programmers manual. The status register has an interrupt level mask in bits 8 to 11. Setting sr to $x7xx sets the mask to 7, which means only NMIs will be acknowledged. $x0xx means the mask is 0, which allows any interrupt. You'll normally see these in Genesis code:

move.w #$2700,sr

which disables interrupts, and

move.w #$2000,sr

which enables them. The Genesis doesn't use all the interrupts, so you'll sometimes see people set sr to $2300, which is sufficient for the HINT and VINT.

koilazka
Interested
Posts: 30
Joined: Mon Nov 30, 2009 1:51 am

Post by koilazka » Sat Mar 20, 2010 11:58 pm

Thanks for that, ill read the programmers manual.
I learnt 68k from the opcode manual, that only has reference on the condition codes generated, sr bits 7-0.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Mar 21, 2010 12:16 am

koilazka wrote:Thanks for that, ill read the programmers manual.
I learnt 68k from the opcode manual, that only has reference on the condition codes generated, sr bits 7-0.
There's not much beyond that which is needed, but the sr is one of those things you should probably get from it, especially the int mask. Read the chapter on exception handling as well. That will help you in making vint/hint routines.

Alex Khan
Very interested
Posts: 77
Joined: Thu Jan 07, 2010 9:51 am

Post by Alex Khan » Mon Mar 22, 2010 11:05 am

Chilly what are the advantages of using v and h interrupts?

Noob question I know.
I need a Black Belt in Game Programming!

Gigasoft
Very interested
Posts: 95
Joined: Fri Jan 01, 2010 2:24 am

Post by Gigasoft » Mon Mar 22, 2010 12:24 pm

It's so that you don't have to actively wait for the line counter to reach a specific value, but can do other things in the meantime.

H interrupts let you know when a specific number of lines have passed, so that you can change something. For example, in Sonic, the H interrupt handler changes the palette to a water palette so that the bottom part of the screen will have this palette.

Alex Khan
Very interested
Posts: 77
Joined: Thu Jan 07, 2010 9:51 am

Post by Alex Khan » Sat Mar 27, 2010 5:47 am

Gigasoft wrote:It's so that you don't have to actively wait for the line counter to reach a specific value, but can do other things in the meantime.

H interrupts let you know when a specific number of lines have passed, so that you can change something. For example, in Sonic, the H interrupt handler changes the palette to a water palette so that the bottom part of the screen will have this palette.
This is good ... Gigasoft where can i read more about V and h interrupts considering my knowledge of Asm is limited?
I need a Black Belt in Game Programming!

Post Reply