From b78bff9307de43e7d7f1dc66b4f367b3d3d81449 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 12 Jun 2021 21:28:43 -0700 Subject: extract a helper to render fonts outside video RAM --- 101screen.subx | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to '101screen.subx') diff --git a/101screen.subx b/101screen.subx index 2aab293d..22ce490c 100644 --- a/101screen.subx +++ b/101screen.subx @@ -6,6 +6,19 @@ == code pixel-on-real-screen: # x: int, y: int, color: int + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # + (pixel-on-screen-buffer *Video-memory-addr *(ebp+8) *(ebp+0xc) *(ebp+0x10)) +$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 # . prologue 55/push-ebp 89/<- %ebp 4/r32/esp @@ -13,26 +26,26 @@ pixel-on-real-screen: # x: int, y: int, color: int 50/push-eax 51/push-ecx # bounds checks - 8b/-> *(ebp+8) 0/r32/eax + 8b/-> *(ebp+0xc) 0/r32/eax 3d/compare-eax-and 0/imm32 - 7c/jump-if-< $pixel-on-real-screen:end/disp8 + 7c/jump-if-< $pixel-on-screen-buffer:end/disp8 3d/compare-eax-and 0x400/imm32/screen-width=1024 - 7d/jump-if->= $pixel-on-real-screen:end/disp8 - 8b/-> *(ebp+0xc) 0/r32/eax + 7d/jump-if->= $pixel-on-screen-buffer:end/disp8 + 8b/-> *(ebp+0x10) 0/r32/eax 3d/compare-eax-and 0/imm32 - 7c/jump-if-< $pixel-on-real-screen:end/disp8 + 7c/jump-if-< $pixel-on-screen-buffer:end/disp8 3d/compare-eax-and 0x300/imm32/screen-height=768 - 7d/jump-if->= $pixel-on-real-screen:end/disp8 + 7d/jump-if->= $pixel-on-screen-buffer:end/disp8 # eax = y*1024 + x - 8b/-> *(ebp+0xc) 0/r32/eax + 8b/-> *(ebp+0x10) 0/r32/eax c1/shift 4/subop/left %eax 0xa/imm8 - 03/add-> *(ebp+8) 0/r32/eax + 03/add-> *(ebp+0xc) 0/r32/eax # eax += location of frame buffer - 03/add-> *Video-memory-addr 0/r32/eax + 03/add-> *(ebp+8) 0/r32/eax # *eax = color - 8b/-> *(ebp+0x10) 1/r32/ecx + 8b/-> *(ebp+0x14) 1/r32/ecx 88/byte<- *eax 1/r32/CL -$pixel-on-real-screen:end: +$pixel-on-screen-buffer:end: # . restore registers 59/pop-to-ecx 58/pop-to-eax -- cgit 1.4.1-2-gfad0