CON ' This program will display 3 boxes on the screen ' The boxes are colored RED GREEN BLUE ' This version uses a PS2 Keyboard proto/demo configuration. ' Left/Right selects the box ' Up/Down changes the colors ' Mark Bramwell, Sept 16, 2007 ' Adapted to PS2 By Jeff Ledger Sept 16, 2007 -Great Idea Mark! ' Adapted to PropTerminal by Andy Schenk, Sept 18, 2007 ' - press Return to transfer the color values to the Terminal, add a comment ' - when all done: Write it to the clipboard with 'Copy Text' in File-menu ' - Insert it in the IDE with Control-V _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 x_tiles = 16 y_tiles = 12 paramcount = 14 display_base = $5000 lines = 5 thickness = 2 CMD_nothing = 0 CMD_Down = 1 CMD_Up = 2 CMD_Left = 3 CMD_Right = 4 CMD_Return = 5 CMD_Clear = 6 OBJ tv : "tv" gr : "graphics" key : "pc_interface" ' Keyboard Driver num : "numbers" VAR long tv_status '0/1/2 = off/visible/invisible read-only long tv_enable '0/? = off/on write-only long tv_pins '%ppmmm = pins write-only long tv_mode '%ccinp = chroma,interlace,ntsc/pal,swap write-only long tv_screen 'pointer to screen (words) write-only long tv_colors 'pointer to colors (longs) write-only long tv_hc 'horizontal cells write-only long tv_vc 'vertical cells write-only long tv_hx 'horizontal cell expansion write-only long tv_vx 'vertical cell expansion write-only long tv_ho 'horizontal offset write-only long tv_vo 'vertical offset write-only long tv_broadcast 'broadcast frequency (Hz) write-only long tv_auralcog 'aural fm cog write-only word screen[x_tiles * y_tiles] long colors[64] byte x[lines] byte y[lines] byte xs[lines] byte ys[lines] long keycode byte CMD_Code byte CurrentTile byte ColorHEX[9] long ColorLong byte ColorCode byte DisplayedValue[4] byte CurrentValue[4] long BarWidth PUB Start | i, dx, dy key.start(31,30) ' Start keyboard driver 'start tv longmove(@tv_status, @tvparams, paramcount) tv_screen := @screen tv_colors := @colors tv.start(@tv_status) 'init colors repeat i from 0 to 63 colors[i] := $3b0ac8aa 'start and setup graphics gr.start gr.setup(x_tiles, y_tiles, 128, 96, display_base) 'clear bitmap gr.clear 'init tile screen repeat dx from 0 to tv_hc - 1 repeat dy from 0 to tv_vc - 1 screen[dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + ((dy & $3F) << 10) gr.colorwidth(3,14) gr.box(-128,-101,256,200) ' ,, h-size, v-size ' top line colors[0] := $0a050a02 ' blue gr.textmode(3,1,6,5) gr.colorwidth(2,1) ' color, width gr.text(0,87,string("Color Codes")) gr.textmode(2,2,6,5) ' width, height, spacing '------------------------------ ' draw three boxes '------------------------------ gr.colorwidth(0,1) ' color, width gr.text(-40,32,string("0")) gr.box(-90,20,35,25) gr.colorwidth(1,1) ' color, width gr.text(35,32,string("1")) gr.box(-15,20,35,25) gr.colorwidth(2,1) ' color, width gr.text(105,32,string("2")) gr.box(60,20,35,25) gr.finish ShowSlider PUB ShowSlider ' Some known color codes ' ' 05/06 = white ' 18 = bright orange ' ab = orange ' 0a = blue ' 0b = lightblue ' 3b = cyan ' 4b = green ' 68 = pink ' 88 = bright blue ' 8b = brown ' 9b = orange ' a3 = dark gray ' a4/a5 = gray ' aa = red ' b8/c8 = bright green ' f8 = yellow colors[3] := $440b6b9b colors[4] := $440b6b9b colors[5] := $3b9b06aa colors[6] := $3b9b06aa colors[7] := $3ba2a4a3 colors[8] := $3b9b06aa colors[9] := $3b9b06aa colors[10] := $3b9b06aa colors[11] := $3b9b06aa DisplayedValue := -1 CurrentValue := 128 CurrentTile := 0 ColorLong := Colors[4] ' we tear apart the long bytemove(@CurrentValue[0], @ColorLong, 1) bytemove(@CurrentValue[1], @ColorLong+1, 1) bytemove(@CurrentValue[2], @ColorLong+2, 1) bytemove(@CurrentValue[3], @ColorLong+3, 1) gr.textmode(2,2,6,5) ' width, height, spacing gr.colorwidth(1,1) ' color, width gr.text(0,0,String("Color=")) gr.text(39,0,num.toStr(CurrentTile,num#dec)) gr.textmode(1,2,6,5) ' width, height, spacing gr.colorwidth(1,0) ' color, width gr.text(0,-80,string(" Left/Right and Up/Down to Change ")) gr.finish ' black border gr.colorwidth(2,14) gr.box(-100,-32,200,16) repeat IR_DecodeKeycode(keycode) Case CMD_Code CMD_Down: if CurrentValue[CurrentTile] <> 0 CurrentValue[CurrentTile] := CurrentValue[CurrentTile] - 1 CMD_Up: if CurrentValue[CurrentTile] <> 255 CurrentValue[CurrentTile] := CurrentValue[CurrentTile] + 1 CMD_Left: if CurrentTile <> 0 gr.textmode(2,2,6,5) ' width, height, spacing gr.colorwidth(3,1) ' color, width gr.text(39,0,num.toStr(CurrentTile,num#dec)) CurrentTile := CurrentTile - 1 gr.colorwidth(1,1) ' color, width gr.text(39,0,num.toStr(CurrentTile,num#dec)) CMD_Right: if CurrentTile <> 3 gr.textmode(2,2,6,5) ' width, height, spacing gr.colorwidth(3,1) ' color, width gr.text(39,0,num.toStr(CurrentTile,num#dec)) CurrentTile := CurrentTile + 1 gr.colorwidth(1,1) ' color, width gr.text(39,0,num.toStr(CurrentTile,num#dec)) CMD_Return: key.out(13) key.out("$") key.hex(ColorLong,8) key.str(string(" '")) CMD_Clear: key.out(0) CMD_Nothing: other: key.out(CMD_Code) if DisplayedValue <> CurrentValue[CurrentTile] ' dark gray inside gr.colorwidth(0,10) gr.box(-97,-30,194,12) ' light gray value gr.colorwidth(1,10) BarWidth := ((CurrentValue[CurrentTile] * 178) / 255) + 14 gr.box(-97,-30,BarWidth,12) ' 3rd value range = 1 to 192 gr.textmode(2,2,6,5) ' width, height, spacing gr.colorwidth(3,1) ' color, width gr.text(0,-47,num.toStr(DisplayedValue,num#hex3)) gr.colorwidth(1,1) ' color, width gr.text(0,-47,num.toStr(CurrentValue[CurrentTile],num#hex3)) gr.finish DisplayedValue := CurrentValue[CurrentTile] Case CurrentTile ' we put the long back together 0: bytemove(@ColorLong, @CurrentValue[CurrentTile], 1) 1: bytemove(@ColorLong+1, @CurrentValue[CurrentTile], 1) 2: bytemove(@ColorLong+2, @CurrentValue[CurrentTile], 1) 3: bytemove(@ColorLong+3, @CurrentValue[CurrentTile], 1) Colors[3] := ColorLong Colors[4] := ColorLong ShowColorCode PUB ShowColorCode ' Manually builds a string ' We can not use the num library because of the signed long gives us negative values colors[1] := $3b06c8aa colors[2] := $3b06c8aa gr.colorwidth(3,1) ' color, width gr.box(-60,50,140,26) gr.finish gr.textmode(2,2,6,5) ' width, height, spacing gr.colorwidth(2,1) ' color, width bytemove(@ColorCode, @ColorLong+3, 1) gr.text(-45, 64,num.toStr(ColorCode,num#hex3)) gr.finish bytemove(@ColorCode, @ColorLong+2, 1) gr.text(-15, 64,num.toStr(ColorCode,num#hex3)) gr.finish bytemove(@ColorCode, @ColorLong+1, 1) gr.text(15, 64,num.toStr(ColorCode,num#hex3)) gr.finish bytemove(@ColorCode, @ColorLong, 1) gr.text(45, 64,num.toStr(ColorCode,num#hex3)) gr.finish PUB IR_DecodeKeycode(KeyCodeIN) | k k := key.key Case k ' Here is where we map the code sent from the remote to the function it performs ' Sony Remotes: Up/Down/Left/Right arrows ' Main Set 194: CMD_Code := CMD_Up 195: CMD_Code := CMD_Down 192: CMD_Code := CMD_Left 193: CMD_Code := CMD_Right 13: CMD_Code := CMD_Return $C8: CMD_Code := CMD_Clear 0: CMD_Code := CMD_Nothing Other: CMD_Code := k DAT tvparams long 0 'status long 1 'enable long %001_0101 'pins long %0000 'mode (PAL: %0001) long 0 'screen long 0 'colors long x_tiles 'hc long y_tiles 'vc long 10 'hx (PAL: 12) long 1 'vx long 0 'ho long 0 'vo long 0 'broadcast long 0 'auralcog