question about color and HBlankInt
Moderators: BigEvilCorporation, Mask of Destiny
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
question about color and HBlankInt
The screen is divided into two parts.The upper part of using a color palette,and the bottom half of another color palette.Simulator displays the correct,but Game console displays an error.There is a line in the middle of the screen
This is my demo source code:
https://www.box.com/files#/files/0/f/0/1/f_6228473143
and this is shot:
This is my demo source code:
https://www.box.com/files#/files/0/f/0/1/f_6228473143
and this is shot:
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
Code: Select all
;********************************************
NMI: ;IE0 Vertical Interrupt (Level 6)
movem.l d0-a7,-(sp)
move.w #$8A70,$C00004
move.w #$8014,$C00004 ;open IRQ
MOVE.L #$C0000000,$C00004 ;CRAM WRITE
MOVE.W #$3F,D0 ;PALETTE 0;64 COLOR
LEA.L title_a_PALETTE_OFFSET,A3
?Send_PAL
MOVE.W (A3)+,$C00000
DBF D0,?Send_PAL
JSR TFMMUSICNMI
jsr nmi_sound
MOVE.l #0,m_NMIFlag
movem.l (sp)+,d0-a7
RTE
;********************************************
IRQ:
movem.l d0-a7,-(sp)
MOVE.L #$C0000000,$C00004 ;CRAM WRITE
MOVE.W #$3F,D0 ;PALETTE 0;64 COLOR
LEA.L title_b_PALETTE_OFFSET,A3
?Send_PAL
MOVE.W (A3)+,$C00000
DBF D0,?Send_PAL
movem.l (sp)+,d0-a7
RTE
;********************************************
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
If you write the palette during active display the real hardware show pixel garbage in active screen. You should tunr off the VDP while you're updating the palette or take care about modifying it only during the HBlank.
Of course you can't update the whole palette during a single hblank, at best you can update 4/5 entries i guess...
Of course you can't update the whole palette during a single hblank, at best you can update 4/5 entries i guess...
Last edited by Stef on Fri Feb 15, 2013 3:20 pm, edited 1 time in total.
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
I modified the code as follows:Stef wrote:If you write the palette during active display the real hardware show pixel garbage in active screen. You should tunr off the VDP while you're updating the palette or take care about modifying it only during the HBlank.
Of course you can't update the whole palette during a single hblank, at beast you can update 4/5 entries i guess...
Code: Select all
;**************************************************************
IRQ: ;
movem.l d0-a7,-(sp)
move.w #$816C,$C00004
MOVE.L #$C0600000,$C00004 ;CRAM WRITE
MOVE.W #$3F-$30,D0 ;PALETTE 0;64 COLOR
LEA.L title_b_PALETTE_OFFSET+$60,A3
?Send_PAL
MOVE.W (A3)+,$C00000
DBF D0,?Send_PAL
move.w #$817C,$C00004
movem.l (sp)+,d0-a7
RTE
;**************************************************************
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
I read the article "HBlank the Timings" from viewtopic.php?t=388&highlight=hblank
The H-INT isn't HBLANK start
How do I know the HBLANK began?
Code: Select all
LINE N LINE N + 1
|----------------------------------------------|--------------------
<HBS>---------<HBE>----------------------------<HBS>
|
<H-INT>
|
<LRE>
HBS -> HBLANK start
HBE -> HBLANK end
H-INT -> H-INT Trigger
LRE -> Line rendering
How do I know the HBLANK began?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
You can check the VDP status flag to know if you are in the hblank, you can also use the VDP HV counter for that purpose.zhengyaxin_8bit wrote:I read the article "HBlank the Timings" from viewtopic.php?t=388&highlight=hblankThe H-INT isn't HBLANK startCode: Select all
LINE N LINE N + 1 |----------------------------------------------|-------------------- <HBS>---------<HBE>----------------------------<HBS> | <H-INT> | <LRE> HBS -> HBLANK start HBE -> HBLANK end H-INT -> H-INT Trigger LRE -> Line rendering
How do I know the HBLANK began?
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Only 3 color updates fit into offscreen area per line.
Disable VDP rendering as Hint happens, DMA in one or 2 palettes and enable VDP again. You will lose some/most/all sprites for that line, but that pushes many palette writes into offscreen area.
Disable VDP rendering as Hint happens, DMA in one or 2 palettes and enable VDP again. You will lose some/most/all sprites for that line, but that pushes many palette writes into offscreen area.
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
I improved the code,
The new effect here
http://s1048.beta.photobucket.com/user/ ... 2.png.html
Code: Select all
IRQ:
movem.l d0-a7,-(sp)
?WAIT_HBLANK:
MOVE.W $C00004,D0
AND.W #$02,D0
CMP.W #$02,D0
BEQ ?WAIT_HBLANK
MOVE.L #$C0600000,$C00004 ;CRAM WRITE
MOVE.L m_AddrSave,A3
MOVE.l (A3)+,$C00000 ;8*4/2=16
MOVE.l (A3)+,$C00000
MOVE.l (A3)+,$C00000
MOVE.l (A3)+,$C00000
MOVE.l (A3)+,$C00000
MOVE.l (A3)+,$C00000
MOVE.l (A3)+,$C00000
MOVE.l (A3)+,$C00000
movem.l (sp)+,d0-a7
RTE
http://s1048.beta.photobucket.com/user/ ... 2.png.html
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
You want to write too many colors. You can only do 3 colors in one line without garbage showing up. Just 3.
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 616
- Joined: Thu Nov 30, 2006 6:30 am
You can do as many as 8 colors per line if you combine vcounter polling, disabling the display during transfer and DMA. You'll want to do most of the DMA setup sometime before HBLANK and you'll want the command words to disable the display, start the DMA operation and turn the display back on again in registers. As TmEE noted, you lose all your sprites for the line this way, but you won't get any garbage. You still won't be able to transfer 16 colors in a single line like you're trying to though.
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
As you said,I do these changesTmEE co.(TM) wrote:You want to write too many colors. You can only do 3 colors in one line without garbage showing up. Just 3.
Code: Select all
IRQ:
movem.l d0-a7,-(sp)
;?WAIT_HBLANK:
; MOVE.W $C00004,D0
; AND.W #$02,D0
; CMP.W #$02,D0
; BEQ ?WAIT_HBLANK
MOVE.L #$C0600000,$C00004 ;CRAM WRITE
MOVE.L m_AddrSave,A3
MOVE.W (A3)+,$C00000
MOVE.W (A3)+,$C00000
MOVE.W (A3)+,$C00000
movem.l (sp)+,d0-a7
RTE
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
I just do the experiment,TmEE co.(TM) is right.
I modify the program:
The line 40-51 no garbage
I modify the program:
Code: Select all
IRQ:
movem.l d0-a7,-(sp)
?WAIT_HBLANK:
MOVE.W $C00004,D0
AND.W #$02,D0
CMP.W #$02,D0
BEQ ?WAIT_HBLANK
NOP ;1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP ;10
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP ;20
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP ;30
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP ;39 have pix garbage
NOP ;40 min
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP ;51 max
NOP ;52 Have pix garbage
MOVE.L #$C0600000,$C00004 ;CRAM WRITE
MOVE.L m_AddrSave,A3
MOVE.W (A3)+,$C00000
MOVE.W (A3)+,$C00000
MOVE.W (A3)+,$C00000
movem.l (sp)+,d0-a7
RTE
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
You can do better asm code so you can transfer more colors :
Prepare your command write (CRAM write) in $C00004 ahead then cache $C00000 in A0 register and prepare values to copy in Dx registers.
Then at the good moment (just when HBlank start) you just do a single MOVEM.L instruction to copy as much color data as much as possible during the HBlank period.
Prepare your command write (CRAM write) in $C00004 ahead then cache $C00000 in A0 register and prepare values to copy in Dx registers.
Then at the good moment (just when HBlank start) you just do a single MOVEM.L instruction to copy as much color data as much as possible during the HBlank period.