start double-buffering
Amazing how much difference it makes even when the implementation is so naive and slow.
This commit is contained in:
parent
2952a29960
commit
fd57c48c60
|
@ -33,9 +33,7 @@ __check-mu-array-bounds: # index: int, elem-size: int, arr-size: int, function-
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 " is too large for array '" 3 0) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 " is too large for array '" 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3 0) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "'" 3 0) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "'" 3 0) # 3=cyan
|
||||||
{
|
(abort "")
|
||||||
eb/jump loop/disp8
|
|
||||||
}
|
|
||||||
# never gets here
|
# never gets here
|
||||||
$__check-mu-array-bounds:end:
|
$__check-mu-array-bounds:end:
|
||||||
# . restore registers
|
# . restore registers
|
||||||
|
@ -53,9 +51,7 @@ __check-mu-array-bounds:overflow:
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset to array '" 3 0) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 ": offset to array '" 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3 0) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 *(ebp+0x18) 3 0) # 3=cyan
|
||||||
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "' overflowed 32 bits" 3 0) # 3=cyan
|
(draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "' overflowed 32 bits" 3 0) # 3=cyan
|
||||||
{
|
(abort "")
|
||||||
eb/jump loop/disp8
|
|
||||||
}
|
|
||||||
# never gets here
|
# never gets here
|
||||||
|
|
||||||
__mu-abort-null-index-base-address:
|
__mu-abort-null-index-base-address:
|
||||||
|
|
|
@ -516,3 +516,42 @@ fn pixel-index _screen: (addr screen), x: int, y: int -> _/ecx: int {
|
||||||
result <- add x
|
result <- add x
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# double-buffering primitive
|
||||||
|
# 'screen' must be a fake screen. 'target-screen' is usually real.
|
||||||
|
# Both screens must have the same size.
|
||||||
|
fn copy-pixels _screen: (addr screen), target-screen: (addr screen) {
|
||||||
|
var screen/esi: (addr screen) <- copy _screen
|
||||||
|
var pixels-ah/eax: (addr handle array byte) <- get screen, pixels
|
||||||
|
var _pixels/eax: (addr array byte) <- lookup *pixels-ah
|
||||||
|
var pixels/edi: (addr array byte) <- copy _pixels
|
||||||
|
var width-a/edx: (addr int) <- get screen, width
|
||||||
|
var width/edx: int <- copy *width-a
|
||||||
|
width <- shift-left 3/log2-font-width
|
||||||
|
var height-a/ebx: (addr int) <- get screen, height
|
||||||
|
var height/ebx: int <- copy *height-a
|
||||||
|
height <- shift-left 4/log2-font-height
|
||||||
|
var i/esi: int <- copy 0
|
||||||
|
var y/ecx: int <- copy 0
|
||||||
|
{
|
||||||
|
# screen top left pixels x y width height
|
||||||
|
compare y, height
|
||||||
|
break-if->=
|
||||||
|
var x/eax: int <- copy 0
|
||||||
|
{
|
||||||
|
compare x, width
|
||||||
|
break-if->=
|
||||||
|
{
|
||||||
|
var color-addr/ebx: (addr byte) <- index pixels, i
|
||||||
|
var color/ebx: byte <- copy-byte *color-addr
|
||||||
|
var color2/ebx: int <- copy color
|
||||||
|
pixel target-screen, x, y, color2
|
||||||
|
}
|
||||||
|
x <- increment
|
||||||
|
i <- increment
|
||||||
|
loop
|
||||||
|
}
|
||||||
|
y <- increment
|
||||||
|
loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,11 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
|
||||||
var env-storage: environment
|
var env-storage: environment
|
||||||
var env/esi: (addr environment) <- address env-storage
|
var env/esi: (addr environment) <- address env-storage
|
||||||
initialize-environment env
|
initialize-environment env
|
||||||
render screen, env
|
var second-buffer: screen
|
||||||
|
var second-screen/edi: (addr screen) <- address second-buffer
|
||||||
|
initialize-screen second-screen, 0x80, 0x30, 1/include-pixels
|
||||||
|
render second-screen, env
|
||||||
|
copy-pixels second-screen, screen
|
||||||
{
|
{
|
||||||
edit keyboard, env
|
edit keyboard, env
|
||||||
var play?/eax: (addr boolean) <- get env, play?
|
var play?/eax: (addr boolean) <- get env, play?
|
||||||
|
@ -24,7 +28,8 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
|
||||||
{
|
{
|
||||||
break-if-=
|
break-if-=
|
||||||
step env
|
step env
|
||||||
render screen, env
|
render second-screen, env
|
||||||
|
copy-pixels second-screen, screen
|
||||||
}
|
}
|
||||||
linger env
|
linger env
|
||||||
loop
|
loop
|
||||||
|
|
Loading…
Reference in New Issue