Found it!jgharston wrote:For instance, flashing colours can easily be done by writing the pallete on every x VSync events. Somewhere I've got code that does this to allow non-completementary flashing on the Beeb (eg Red/Blue, Red/White, Black/Yellow) instead of the built-in complementary flashing (eg Red/Cyan, Black/White, Blue/Yellow).
Code: Select all
10 REM > Flash
20 REM Non-complementary flashing
30 REM Only works 16-colour MODE
40 :
50 MODE &82
60 DIM mcode% 256
70 eventv=&220
80 palette=&36F
90 FOR P=0 TO 1
100 P%=mcode%
110 [OPT P*2
120 .event
130 CMP #4:BEQ vsync
140 .oldevent
150 JMP 0
160 .vsync
170 LDA &251:CMP #1:BNE oldvsync :\ flash counter
180 TXA:PHA:LDX #15
190 .loop
200 LDA palette,X
210 LSR A:LSR A:LSR A:LSR A :\ Flip colours
220 EOR palette,X:STA palette,X
230 AND #&0F:EOR #&07:STA temp :\ A=physical colour
240 TXA:ASL A:ASL A:ASL A:ASL A :\ A=%llll0000
250 ORA temp:STA &FE21 :\ A=%llllpppp
260 DEX:BPL loop
270 PLA:TAX
280 .oldvsync
290 LDA #4:JMP oldevent
300 .temp :EQUB 0
310 ]NEXT
320 :
330 IF eventv?1<&80:END
340 oldevent?1=eventv?0
350 oldevent?2=eventv?1
360 eventv?0=event AND 255
370 eventv?1=event DIV 255
380 *FX14,4
The top nybble of each palette entry at &36F-&37E is EOR'd with the bottom nybble on each flash timeout, so you can do ?(&36F+logical)=colour1 + 16*(colour1 EOR colour2) to flash between any two physical colours.
Edit: demo!
