ô > PALSUB/S 5ô Source for PALSUB - 12-bit palette control code =ô Code is position independent, so can be loaded anywhere (: 29ô Use in a program running in the I/O processor with: <ô DIM PALETTE 200 F)ô OSCLI "LOAD PALSUB "+STR$~PALETTE Pô CALL PALETTE+3 Zô d ô To change the palette use: n*ô CALL PALETTE,colour,red,green,blue x0ô where colour,red,green,blue are all 0-15 ‚: Œ*ݤif(A%):çA%:z%=-1:=opt% ‹ z%=P%:=opt% –;ݤendif:çz%=-1:=opt% ‹ z%=P%-z%:P%=P%-z%:O%=O%-z%:=opt%  : ªÞ mcode% &100 ´(clwyd% =¹ :ô Clwyd Palette Expander ¾ cc500% =£ :ô CTS Colour Card È'pmate% =£ :ô WildVision PaletteMate Òchamel%=£ :ô Chameleon Üvnula% =£ :ô VideoNuLA æ: ð òassem:à ú:  Ýòassem load%=&C00 OSBYTE=&FFF4 "ã opt%=4 ¸ 7 ˆ 3 ,P%=load%:O%=mcode% 6 [OPT opt% @ .load% J0CLC:BCC select :\ Main entry point T .exec% ^ .L0C1A h5RTS :\ Initialise at exec%+3 r6.select :\ Get initial parameters |@LDA #&00:STA &70 :\ &70=0, number of parameters read †:: :STA &72 :\ &72=0, index into Ö buffer 5STA &73:LDA #&06:STA &74 :\ &73/4=>&600, Ö buffer š8LDA &0600:STA &71 :\ &71=number of parameters ¤: ®9CMP #&04:BNE L0C1A :\ Not four parameters, exit ¸ .L0C09 Â7LDY &72 :\ Get index into Ö buffer Ì+INY:LDA (&73),Y:STA &75 :\ &75/6=>data ÖINY:LDA (&73),Y:STA &76 à(INY:LDA (&73),Y:STA &77 :\ &77=type ê2STY &72 :\ Save updated index ô: þ2LDY #&00:LDA (&75),Y:TAX :\ Get byte 0 of data 2INY:LDA (&75),Y :\ Get byte 1 of data : -PHA:LDA &77 :\ Get data type &'CMP #&04:BEQ L0C70 :\ Integer 0)CMP #&05:BNE L0C73 :\ Not float :TXA:€ #&7F:TAX DPLA:„A #&80 N/CPX #&00:BEQ L0C73 :\ &00,&00 -> zero X8CLC :\ Convert float to integer b .L0C6A lROL A:DEX:BNE L0C6A v ROL A:PHA € .L0C70 Š/PLA:TAX :\ Already integer ” .L0C73 žTXA ¨: ².LDX &70:STA &80,X :\ Store at &80+n ¼6INC &70:LDA &70 :\ Step to next parameter Æ3CMP &71:BNE L0C09 :\ Loop until all done Ð: Ú0\ Now use the four bytes at &80-&83, C,R,G,B ä.LDA #&13:JSR OSBYTE :\ Wait for HSync î \ 100 ø: OPT ¤if(clwyd%)  \ Clwyd Expander: \ Write to user port:  \ %cccc1000 - colour number *\ %rrrr1001 - RED 4\ %gggg1010 - GREEN >\ %bbbb1011 - BLUE H.\ Data written with b3=0, b3=1, b3=0, b3=1 R\ ie, write xxxx0xxx \\ write xxxx1xxx f\ write xxxx0xxx p\ write xxxx1xxx z\ „*LDA #&FF:STA &FE62 :\ I/O=output ŽLDA #&00:STA &FE60 ˜ LDX #0 ¢ .L0CA0 ¬+LDA &80,X :\ Get C,R,G,B ¶#ASL A:ASL A:ASL A:ASL A :\ *16 À„A #&08:STA &80,X Ê@TXA:„A &80,X :\ %nnnn10yy, yy=0/1/2/3 for C/R/G/B Ô,€ #&F7:STA &FE60 :\ Write xxxx0xxx Þ-„A #&08:STA &FE60 :\ Write xxxx1xxx è,€ #&F7:STA &FE60 :\ Write xxxx0xxx ò.LDA #&00:STA &FE60 :\ Write xxxx1xxx üINX:CPX #4:BNE L0CA0 RTS OPT ¤endif : $OPT ¤if(cc500%) .\ CTS Colour Card 500: 8\ Write to colour card: B!\ %xxxxrrrr to &FCA0+L - RED L#\ %xxxxgggg to &FCA8+L - GREEN V"\ %xxxxbbbb to &FCB0+L - BLUE `\ j+LDA &80:€ #7:TAX :\ Colour number t)LDA &81:STA &FCA0,X :\ Write RED ~+LDA &82:STA &FCA8,X :\ Write GREEN ˆ*LDA &83:STA &FCB0,X :\ Write BLUE ’RTS œOPT ¤endif ¦: °OPT ¤if(chamel%) º\ Chameleon: Ä\ Write to User port: Î\ %000xrrrr - inverted RED Ø!\ %010xgggg - inverted GREEN â \ %100xbbbb - inverted BLUE ì \ %111xcccc - colour number ö\ &LDA #&FF:STA &FE62 :\ I/O=output  0LDA #&AE:STA &FE6C :\ Toggle CB2 on writes LDA &80:„A #&E0:STA &FE60 #LDA &81:„A #&00:‚ #15:STA &FE60 (#LDA &82:„A #&40:‚ #15:STA &FE60 2#LDA &83:„A #&80:‚ #15:STA &FE60 <RTS FOPT ¤endif P: ZOPT ¤if(vnula%) d\ VideoNuLA: n.\ Write to &FE23=%ccccrrrr, then %ggggbbbb x\ ‚#LDA &80:ASL A:ASL A:ASL A:ASL A Œ„A &81:STA &FE23 –#LDA &82:ASL A:ASL A:ASL A:ASL A  „A &83:STA &FE23 ªRTS ´OPT ¤endif ¾: È]:í Ò;ñ "*SAVE PALSUB ";~mcode%;" ";~O%;" ";~exec%;" ";~load% Üá æ: ð Ýòall úÞ mcode% &100 8clwyd%=1:cc500%=0:pmate%=0:chamel%=0:vnula%=0:òassem 3ÿ "SAVE PALSUBcl "+Ã~mcode%+" "+Ã~O%+" C03 C00" 8clwyd%=0:cc500%=1:pmate%=0:chamel%=0:vnula%=0:òassem "3ÿ "SAVE PALSUBcc "+Ã~mcode%+" "+Ã~O%+" C03 C00" ,8clwyd%=0:cc500%=0:pmate%=1:chamel%=0:vnula%=0:òassem 63ÿ "SAVE PALSUBpm "+Ã~mcode%+" "+Ã~O%+" C03 C00" @8clwyd%=0:cc500%=0:pmate%=0:chamel%=1:vnula%=0:òassem J3ÿ "SAVE PALSUBch "+Ã~mcode%+" "+Ã~O%+" C03 C00" T8clwyd%=0:cc500%=0:pmate%=0:chamel%=0:vnula%=1:òassem ^3ÿ "SAVE PALSUBvn "+Ã~mcode%+" "+Ã~O%+" C03 C00" há ÿ