For anything related to VDP (plane, color, sprite, tiles)
Moderators: BigEvilCorporation, Mask of Destiny
-
M-374 LX
- Very interested
- Posts: 61
- Joined: Mon Aug 11, 2008 10:15 pm
-
Contact:
Post
by M-374 LX » Sun Mar 23, 2014 2:12 am
While trying to use the horizontal interrupts to change a palette every line, the palette actually changes every two lines. The same happens with different codes I have tried. What may be wrong?
Here is one of those codes:
Code: Select all
HBL:
add.w #1,cur_scanline
tst.b color_change_enabled
jeq endHBL
moveq #0, %d0
moveq #0, %d1
move.w cur_scanline,%d0
and.w #1,%d0
tst.w %d0
jeq otherColor
move.w #0x888,%d0
move.w #0x0C0,%d1
jmp afterColor
otherColor:
move.w #0xFFF,%d0
move.w #0x0E0,%d1
afterColor:
move.l #0xC0020000,0xC00004
move.w %d0,0xC00000
move.l #0xC00A0000,0xC00004
move.w %d1,0xC00000
endHBL:
rte
Last edited by
M-374 LX on Sun Mar 23, 2014 5:30 pm, edited 2 times in total.
-
r57shell
- Very interested
- Posts: 478
- Joined: Sun Dec 23, 2012 1:30 pm
- Location: Russia
-
Contact:
Post
by r57shell » Sun Mar 23, 2014 10:28 am
two possible reasons:
1) wrong HBLANK settings
2) long code
-
M-374 LX
- Very interested
- Posts: 61
- Joined: Mon Aug 11, 2008 10:15 pm
-
Contact:
Post
by M-374 LX » Sun Mar 23, 2014 5:17 pm
I have just found the cause of the problem: the VDP register #10 was set to 1 instead of 0.
One more question: is it faster to store the current scanline in the RAM or to read it from VDP port 0xC00008?
-
Chilly Willy
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Post
by Chilly Willy » Sun Mar 23, 2014 6:37 pm
Don't bother. It would be faster to just change a pointer after setting the color... like this.
Code: Select all
HBL:
movea.l next_set,-(sp)
rts
set_1:
move.l #0xC0020000,0xC00004
move.w #0x888,0xC00000
move.l #0xC00A0000,0xC00004
move.w #0x0C0,0xC00000
move.l #set_2,next_set
rte
set_2:
move.l #0xC0020000,0xC00004
move.w #0xFFF,0xC00000
move.l #0xC00A0000,0xC00004
move.w #0x0E0,0xC00000
move.l #set_1,next_set
rte
Don't forget to set next_set = set_1 to start with. You can improve the speed a little with judicious register usage for the addressing rather than using absolute longs. Also, don't forget to save/restore all registers used in the exception. The above code doesn't change any registers. If you used a0 for calling the code, you'd need to add saving/restoring a0.