This is my demo source code:
https://www.box.com/files#/files/0/f/0/1/f_6228473143
and this is shot:

Moderators: BigEvilCorporation, Mask of Destiny
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
;********************************************
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
;**************************************************************
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
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?
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
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
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