Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version something.12
- namespace eval kv_overlay {
- proc drawgrid {} {
- # rrggbbaa
- variable color [list "0xffffff50" "0x0000ff50"]
- for {set x 0} {$x < 33} {incr x} {
- osd create rectangle kv.linex$x -scaled true -relx [expr {($x*8)} ] -y 0 -relh 193 -w 1 -rgba [lindex $color [expr {$x % 2}]]
- }
- for {set y 0} {$y < 25} {incr y} {
- osd create rectangle kv.liney$y -scaled true -rely [expr {($y*8)} ] -x 0 -h 1 -relw 257 -rgba [lindex $color [expr {$y % 2}]]
- }
- }
- proc activate_kv2_editor {} {
- osd_widgets::msx_init kv
- osd create text kv.coords -relx -10 -rely -10 -text "Coordinates" -rgba 0xffffff80 -size 8
- drawgrid
- activate_input_layer kv
- FollowMouse
- }
- proc FollowMouse {} {
- osd_widgets::msx_update kv
- lassign [osd info "kv" -mousecoord] x y
- # make sure you register only on the MSX screen
- set x [expr {floor($x)*1}]
- set y [expr {floor($y)*1}]
- if ($x<0) {set x -1}
- if ($y<0) {set y -1}
- if ($y>191) {set y 191}
- if ($x=="Inf") {set x -1}
- if ($y=="Inf") {set y -1}
- if {$x>-1 && $y>-1} {
- poke 0xe265 [expr {int($x / 8)}]
- poke 0xe264 [expr {int($y / 8)}]
- }
- # put coordinates on screen
- osd configure kv.coords -text "[expr {int($x)}] - [expr {int($y)}]"
- bind -layer kv "mouse button1 down" {keymatrixdown 8 0x01}
- bind -layer kv "mouse button1 up" {keymatrixup 8 0x01}
- bind -layer kv "mouse button3 down" {keymatrixdown 4 0x04}
- bind -layer kv "mouse button3 up" {keymatrixup 4 0x04}
- after frame kv_overlay::FollowMouse
- }
- namespace export activate_kv2_editor
- }
- namespace import kv_overlay::*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement