Author: quozl Date: Sat Jan 11 07:24:15 2014 New Revision: 3707 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3707
Log: OLPC XO-1 - screenshot tools
Added: cpu/x86/pc/olpc/sstools/ cpu/x86/pc/olpc/sstools/565.fth cpu/x86/pc/olpc/sstools/README cpu/x86/pc/olpc/sstools/bmp.fth cpu/x86/pc/olpc/sstools/xpm.fth
Added: cpu/x86/pc/olpc/sstools/565.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/olpc/sstools/565.fth Sat Jan 11 07:24:15 2014 (r3707) @@ -0,0 +1,47 @@ +\ dump frame buffer in C565 format + +dev /display +: fb-va ( -- fb ) frame-buffer-adr ; +dend + +: ts$ ( -- adr len ) + time&date >unix-seconds push-decimal 0 <# #s #> pop-base +; + +: putw ( w -- ) wbsplit swap ofd @ fputc ofd @ fputc ; + +: fb-save ( file ( -- ) + writing + " C565" ofd @ fputs + screen-wh swap putw putw + " fb-va" screen-ih $call-method + screen-wh swap drop 0 do ( fb ) + screen-wh drop 0 do ( fb ) + dup w@ ( fb rgb565 ) + putw + wa1+ ( fb' ) + loop ( fb' ) + loop drop ( ) +; + +: fb ( -- ) + ts$ + " u:" + " fb-save %s%s.565" sprintf + screen-ih remove-output + 2dup type cr + ['] evaluate catch ?dup if nip nip .error then + screen-ih add-output +; + +dev /keyboard +: handler? ( scan-code -- flag ) + dup h# 73 ( × ) = if fb true exit then + handle-volume? +; +\ FIXME: during check-alarm, the data stack pointer is in another +\ place, leading to large negative depth and ?enough failures, in +\ particular in writing. +\ ' handler? to scan-handled? +dend +
Added: cpu/x86/pc/olpc/sstools/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/olpc/sstools/README Sat Jan 11 07:24:15 2014 (r3707) @@ -0,0 +1 @@ +screenshot tools for XO-1
Added: cpu/x86/pc/olpc/sstools/bmp.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/olpc/sstools/bmp.fth Sat Jan 11 07:24:15 2014 (r3707) @@ -0,0 +1,74 @@ +\ dump XO-1 frame buffer in BMP24 format + +dev /display +: fb-va ( -- fb ) frame-buffer-adr ; +dend + +: ts$ ( -- adr len ) + time&date >unix-seconds push-decimal 0 <# #s #> pop-base +; + +0 value bmp-width +0 value bmp-height + +h# 36 constant /bmp-hdr +/bmp-hdr buffer: bmp-hdr + +0 value fb-va + +: put-plane ( -- ) + " fb-va" screen-ih $call-method to fb-va + bmp-height 0 do + bmp-width + 0 ?do + fb-va w@ ( rgb565 ) + 565>rgb ( r g b ) + ofd @ fputc + ofd @ fputc + ofd @ fputc + fb-va wa1+ to fb-va + loop + loop +; + +: put-header ( -- ) + " BM" bmp-hdr swap move \ Signature + bmp-width 3 * 4 round-up bmp-height * + dup bmp-hdr h# 22 + le-l! \ Image size + /bmp-hdr + bmp-hdr 2 + le-l! \ File size + + 0 bmp-hdr 6 + le-l! \ Reserved + /bmp-hdr bmp-hdr h# 0a + le-l! \ Image data pixel array offset + h# 28 bmp-hdr h# 0e + le-l! \ Some variant of header size + bmp-width bmp-hdr h# 12 + le-l! + bmp-height negate bmp-hdr h# 16 + le-l! \ Pixel array order top to bottom + 1 bmp-hdr h# 1a + le-w! \ Planes + d# 24 bmp-hdr h# 1c + le-w! \ Bits per pixel + 0 bmp-hdr h# 1e + le-l! \ Compression + + d# 2835 bmp-hdr h# 26 + le-l! \ X pixels/meter + d# 2835 bmp-hdr h# 2a + le-l! \ Y pixels/meter + 0 bmp-hdr h# 2e + le-l! \ Colors used + 0 bmp-hdr h# 32 + le-l! \ Colors important + + bmp-hdr /bmp-hdr ofd @ fputs +; + +: fb-save + writing + screen-wh to bmp-height to bmp-width + + put-header + put-plane + ofd @ fclose +; + +: fb ( -- ) + ts$ + " u:" + " fb-save %s%s.bmp" sprintf + screen-ih remove-output + 2dup type cr + ['] evaluate catch ?dup if nip nip .error then + screen-ih add-output +;
Added: cpu/x86/pc/olpc/sstools/xpm.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/olpc/sstools/xpm.fth Sat Jan 11 07:24:15 2014 (r3707) @@ -0,0 +1,111 @@ +\ save frame buffer in open firmware for screen shots (serial, X bitmap) + +dev /display +: fb-va ( -- fb ) frame-buffer-adr ; +dend + +: .xx ( b -- ) 0 <# # # #> type ; + +\ colour table, +\ list of unique colours in frame buffer +0 value ct \ address of table +d# 62 value /ct \ entries in table (and alphabet utilisation, @-~) + \ d# 62 is insufficient for menu +h# 0 value nct \ next entry to use in table + +\ borrowed from screen-ih +d# 1200 value width +d# 900 value height +h# 0 value fb-va + +: ct-free ( -- ) + ct /ct /w* free-mem +; + +: ct-alloc ( -- ) + /ct /w* alloc-mem to ct +; + +: ct-init ( -- ) + " fb-va" screen-ih $call-method to fb-va + ct /ct /w* erase + h# 0 to nct +; + +: ct-dump ( -- ) \ dump colour table + nct if + nct 0 do + i . ct i wa+ w@ 565>rgb ( r g b ) rot . swap . . cr + loop + then +; + +: ct-add ( pixel -- ) \ add a colour to the table if not already in table + nct if + nct 0 do ( pixel ) + ct i wa+ w@ over = if ( pixel ) \ found + drop unloop exit ( ) \ no action required + then + loop ( pixel ) \ not found + then + nct /ct < if ( pixel ) + ct nct wa+ w! ( ) \ store entry + nct 1+ to nct ( ) \ increment next slot + else + abort" ct: too many colours in frame buffer" + then +; + +: ct-scan ( -- ) \ survey what colours are used + fb-va ( fb ) + height 0 do ( fb ) + width 0 do ( fb' ) + dup w@ ct-add 2+ ( fb' ) + loop ( fb' ) + loop drop ( ) +; + +: xpm-head ( -- ) + ." ! XPM2" cr + width .d height .d + nct .d 1 .d cr + nct 0 do + i h# 40 + emit + ." c #" + ct i wa+ w@ 565>rgb ( r g b ) rot .xx swap .xx .xx cr + loop +; + +: xpm-body ( -- ) + fb-va ( fb ) + height 0 do ( fb ) + width 0 do ( fb ) + dup w@ ( fb pixel ) + nct 0 do ( fb pixel ) + ct i wa+ w@ over = if ( fb pixel ) \ found + i h# 40 + emit ( fb pixel ) + leave ( fb pixel ) + then + loop ( fb pixel ) \ not found + drop ( fb ) + wa1+ ( fb' ) + loop cr ( fb' ) + loop drop ( ) +; + +: .xpm2 \ 256 colour from 16bpp + ct-alloc + ct-init + ct-scan + xpm-head + xpm-body + ct-free +; + +: fb-save ( file ( -- ) + to-file .xpm2 +; + +: ts$ ( -- adr len ) + time&date >unix-seconds push-decimal 0 <# #s #> pop-base +;
openfirmware@openfirmware.info