2020-12-30 05:08:05 +00:00
|
|
|
# Primitives for screen control.
|
2021-01-16 04:30:07 +00:00
|
|
|
#
|
|
|
|
# We need to do this in machine code because Mu doesn't have global variables
|
|
|
|
# yet (for the start of video memory).
|
2020-12-30 05:08:05 +00:00
|
|
|
|
2021-01-14 05:41:45 +00:00
|
|
|
== code
|
|
|
|
|
2021-01-16 04:30:07 +00:00
|
|
|
pixel-on-real-screen: # x: int, y: int, color: int
|
2021-06-13 05:22:54 +00:00
|
|
|
# . prologue
|
|
|
|
55/push-ebp
|
|
|
|
89/<- %ebp 4/r32/esp
|
|
|
|
#
|
|
|
|
(pixel-on-screen-buffer *Video-memory-addr *(ebp+8) *(ebp+0xc) *(ebp+0x10) 0x400 0x300)
|
|
|
|
$pixel-on-real-screen:end:
|
|
|
|
# . epilogue
|
|
|
|
89/<- %esp 5/r32/ebp
|
|
|
|
5d/pop-to-ebp
|
|
|
|
c3/return
|
|
|
|
|
|
|
|
# 'buffer' here is not a valid Mu type: a naked address without a length.
|
|
|
|
pixel-on-screen-buffer: # buffer: (addr byte), x: int, y: int, color: int, width: int, height: int
|
2020-12-30 05:08:05 +00:00
|
|
|
# . prologue
|
|
|
|
55/push-ebp
|
|
|
|
89/<- %ebp 4/r32/esp
|
|
|
|
# . save registers
|
|
|
|
50/push-eax
|
2020-12-30 05:16:28 +00:00
|
|
|
51/push-ecx
|
2021-01-16 04:30:07 +00:00
|
|
|
# bounds checks
|
2021-06-13 05:22:54 +00:00
|
|
|
8b/-> *(ebp+0xc) 0/r32/eax # foo
|
2021-01-16 04:30:07 +00:00
|
|
|
3d/compare-eax-and 0/imm32
|
2021-06-13 05:22:54 +00:00
|
|
|
7c/jump-if-< $pixel-on-screen-buffer:end/disp8
|
|
|
|
3b/compare 0/r32/eax *(ebp+0x18)
|
|
|
|
7d/jump-if->= $pixel-on-screen-buffer:end/disp8
|
|
|
|
8b/-> *(ebp+0x10) 0/r32/eax
|
2021-01-16 04:30:07 +00:00
|
|
|
3d/compare-eax-and 0/imm32
|
2021-06-13 05:22:54 +00:00
|
|
|
7c/jump-if-< $pixel-on-screen-buffer:end/disp8
|
|
|
|
3b/compare 0/r32/eax *(ebp+0x1c)
|
|
|
|
7d/jump-if->= $pixel-on-screen-buffer:end/disp8
|
|
|
|
# eax = y*width + x
|
|
|
|
8b/-> *(ebp+0x10) 0/r32/eax
|
|
|
|
0f af/multiply-> *(ebp+0x18) 0/r32/eax
|
|
|
|
03/add-> *(ebp+0xc) 0/r32/eax
|
2021-06-13 04:41:50 +00:00
|
|
|
# eax += location of frame buffer
|
2021-06-13 05:22:54 +00:00
|
|
|
03/add-> *(ebp+8) 0/r32/eax
|
2021-01-16 04:30:07 +00:00
|
|
|
# *eax = color
|
2021-06-13 05:22:54 +00:00
|
|
|
8b/-> *(ebp+0x14) 1/r32/ecx
|
2021-01-16 04:30:07 +00:00
|
|
|
88/byte<- *eax 1/r32/CL
|
2021-06-13 05:22:54 +00:00
|
|
|
$pixel-on-screen-buffer:end:
|
2020-12-30 05:08:05 +00:00
|
|
|
# . restore registers
|
2020-12-30 05:16:28 +00:00
|
|
|
59/pop-to-ecx
|
2020-12-30 05:08:05 +00:00
|
|
|
58/pop-to-eax
|
|
|
|
# . epilogue
|
|
|
|
89/<- %esp 5/r32/ebp
|
|
|
|
5d/pop-to-ebp
|
|
|
|
c3/return
|