shell: create space to display globals
This commit is contained in:
parent
119aea6d06
commit
d6d28b8c94
|
@ -221,6 +221,36 @@ fn clear-screen screen: (addr screen) {
|
|||
set-cursor-position screen, 0, 0
|
||||
}
|
||||
|
||||
fn clear-rect screen: (addr screen), xmin: int, ymin: int, xmax: int, ymax: int, background-color: int {
|
||||
{
|
||||
compare screen, 0
|
||||
break-if-!=
|
||||
clear-rect-on-real-screen xmin, ymin, xmax, ymax, background-color
|
||||
return
|
||||
}
|
||||
# fake screen
|
||||
set-cursor-position screen, 0, 0
|
||||
var screen-addr/esi: (addr screen) <- copy screen
|
||||
var y/eax: int <- copy ymin
|
||||
var ymax/ecx: int <- copy ymax
|
||||
{
|
||||
compare y, ymax
|
||||
break-if->=
|
||||
var x/edx: int <- copy xmin
|
||||
var xmax/ebx: int <- copy xmax
|
||||
{
|
||||
compare x, xmax
|
||||
break-if->=
|
||||
draw-code-point screen, 0x20/space, x, y, 0/fg, background-color
|
||||
x <- increment
|
||||
loop
|
||||
}
|
||||
y <- increment
|
||||
loop
|
||||
}
|
||||
set-cursor-position screen, 0, 0
|
||||
}
|
||||
|
||||
# there's no grapheme that guarantees to cover every pixel, so we'll bump down
|
||||
# to pixels for a real screen
|
||||
fn clear-real-screen {
|
||||
|
@ -241,6 +271,30 @@ fn clear-real-screen {
|
|||
}
|
||||
}
|
||||
|
||||
fn clear-rect-on-real-screen xmin: int, ymin: int, xmax: int, ymax: int, background-color: int {
|
||||
var y/eax: int <- copy ymin
|
||||
y <- shift-left 4/log-font-height
|
||||
var ymax/ecx: int <- copy ymax
|
||||
ymax <- shift-left 4/log-font-height
|
||||
{
|
||||
compare y, ymax
|
||||
break-if->=
|
||||
var x/edx: int <- copy xmin
|
||||
x <- shift-left 3/log-font-width
|
||||
var xmax/ebx: int <- copy xmax
|
||||
xmax <- shift-left 3/log-font-width
|
||||
{
|
||||
compare x, xmax
|
||||
break-if->=
|
||||
pixel-on-real-screen x, y, background-color
|
||||
x <- increment
|
||||
loop
|
||||
}
|
||||
y <- increment
|
||||
loop
|
||||
}
|
||||
}
|
||||
|
||||
fn screen-grapheme-at screen-on-stack: (addr screen), x: int, y: int -> _/eax: grapheme {
|
||||
var screen-addr/esi: (addr screen) <- copy screen-on-stack
|
||||
var idx/ecx: int <- screen-cell-index screen-addr, x, y
|
||||
|
|
|
@ -22,6 +22,10 @@ fn initialize-globals _self: (addr global-table) {
|
|||
append-primitive self, "cons"
|
||||
}
|
||||
|
||||
fn render-globals screen: (addr screen), _self: (addr global-table), xmin: int, ymin: int, xmax: int, ymax: int {
|
||||
clear-rect screen, xmin, ymin, xmax, ymax, 0x12/bg=grey
|
||||
}
|
||||
|
||||
fn append-primitive _self: (addr global-table), name: (addr array byte) {
|
||||
var self/esi: (addr global-table) <- copy _self
|
||||
var final-index-addr/ecx: (addr int) <- get self, final-index
|
||||
|
|
|
@ -9,11 +9,9 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
|
|||
var sandbox/esi: (addr sandbox) <- address sandbox-storage
|
||||
initialize-sandbox sandbox
|
||||
load-sandbox data-disk, sandbox
|
||||
var width/eax: int <- copy 0
|
||||
var height/ecx: int <- copy 0
|
||||
width, height <- screen-size screen
|
||||
{
|
||||
render-sandbox screen, sandbox, 2/x, 2/y, width, height
|
||||
render-globals screen, globals, 0/x, 0/y, 0x40/xmax, 0x30/screen-height
|
||||
render-sandbox screen, sandbox, 0x40/x, 0/y, 0x80/screen-width, 0x30/screen-height
|
||||
{
|
||||
var key/eax: byte <- read-key keyboard
|
||||
compare key, 0
|
||||
|
|
|
@ -39,7 +39,7 @@ fn allocate-sandbox-with _out: (addr handle sandbox), s: (addr array byte) {
|
|||
##
|
||||
|
||||
fn render-sandbox screen: (addr screen), _self: (addr sandbox), xmin: int, ymin: int, xmax: int, ymax: int {
|
||||
clear-screen screen
|
||||
clear-rect screen, xmin, ymin, xmax, ymax, 0/bg=black
|
||||
var self/esi: (addr sandbox) <- copy _self
|
||||
# data
|
||||
var data-ah/eax: (addr handle gap-buffer) <- get self, data
|
||||
|
|
Loading…
Reference in New Issue