Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace eval kv_overlay {
- #grid part
- proc drawgrid {} {
- osd destroy grid
- osd_widgets::msx_init grid
- # rrggbbaa
- variable color [list "0xffffff50" "0x0000ff50"]
- #setup grid y
- for {set y 0} {$y < 25} {incr y} {
- osd create rectangle grid.liney$y -scaled true -rely [expr {($y*8)} ] -x 0 -h 1 -relw 257 -rgba [lindex $color [expr {$y % 2}]]
- }
- #setup grid x
- for {set x 0} {$x < 33} {incr x} {
- osd create rectangle grid.linex$x -scaled true -relx [expr {($x*8)} ] -y 0 -relh 193 -w 1 -rgba [lindex $color [expr {$x % 2}]]
- }
- #setup coordinates
- osd create text grid.coords -relx 0 -rely -10 -text "Coordinates" -rgba 0xffffff80 -size 6
- osd create text grid.snap -relx 180 -rely -10 -text "Coordinates" -rgba 0xffffff80 -size 6
- #call update procedure
- updatecoords
- }
- proc updatecoords {} {
- osd_widgets::msx_update grid
- set gridsize 8
- lassign [osd info "grid" -mousecoord] x y
- # make sure you register only on the MSX screen
- if ($x=="Inf") {set x 0}
- if ($y=="Inf") {set y 0}
- set x [utils::clip 0 255 [expr {int($x)}]]
- set y [utils::clip 0 191 [expr {int($y)}]]
- # put coordinates on screen
- osd configure grid.coords -text "[expr {int($x)}] - [expr {int($y)}]"
- osd configure grid.snap -text "Snap to $gridsize x $gridsize grid - [expr {int($x / $gridsize)*$gridsize}] - [expr {int($y / $gridsize)*$gridsize}]"
- #call self after frame
- after frame kv_overlay::updatecoords
- }
- #editor part
- proc activate_kv2_editor {} {
- drawgrid
- osd destroy kv
- osd_widgets::msx_init kv
- activate_input_layer kv
- 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}
- FollowMouse
- }
- proc FollowMouse {} {
- osd_widgets::msx_update kv
- lassign [osd info "kv" -mousecoord] x y
- # make sure you register only on the MSX screen
- if ($x=="Inf") {set x 0}
- if ($y=="Inf") {set y 0}
- set x [utils::clip 0 255 [expr {int($x)}]]
- set y [utils::clip 0 191 [expr {int($y)}]]
- # value 28 == in editor
- if {[peek 0xe802] == 28} {
- set ::speed 400
- set ::mute on
- poke 0xe265 [expr {int($x / 8)}]
- poke 0xe264 [expr {int($y / 8)}]
- }
- if {[peek 0xe802] != 28} {
- set ::speed 100
- set ::mute off
- }
- after frame kv_overlay::FollowMouse
- }
- #export the following 2 commands
- namespace export activate_kv2_editor
- namespace export drawgrid
- }
- namespace import kv_overlay::*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement