\
\ Fcode payload for QEMU TCX graphics card
\
\ This is the Forth source for an Fcode payload to initialise
\ the QEMU TCX graphics card.
\

fcode-version3

\
\ Instead of using fixed values for the framebuffer address and the width
\ and height, grab the ones passed in by QEMU/generated by OpenBIOS
\

: openbios-video-addr
  " openbios-video-addr" $find if
    cell+ @
  then
;

: openbios-video-width
  " openbios-video-width" $find if
    cell+ @
  then
;

: openbios-video-height
  " openbios-video-height" $find if
    cell+ @
  then
;

: qemu-tcx-driver-install ( -- )
  openbios-video-addr to frame-buffer-adr
  default-font set-font
  openbios-video-width openbios-video-height over char-width / over char-height /
  fb8-install
;

: qemu-tcx-driver-init
  ['] qemu-tcx-driver-install is-install
;

qemu-tcx-driver-init

end0
