templeos-info/public/Wb/Demo/Lectures/ScrnMemory.HC.HTML

81 lines
5.8 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF2>//This just shows how scrn memory works.</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>//See </span><a href="/Wb/Demo/Lectures/MiniGrLib.HC.HTML#l1"><span class=cF4>::/Demo/Lectures/MiniGrLib.HC</span></a><span class=cF0>
<a name="l3"></a>
<a name="l4"></a></span><span class=cF1>U0</span><span class=cF0> PlotXY(</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y)
<a name="l5"></a>{
<a name="l6"></a></span><span class=cF2>//Scrn bits are revd</span><span class=cF0>
<a name="l7"></a> </span><span class=cF5>LBts</span><span class=cF0>(</span><span class=cFB>text</span><span class=cF0>.vga_alias,y*</span><span class=cF3>GR_WIDTH</span><span class=cF0>+x^7);
<a name="l8"></a>}
<a name="l9"></a>
<a name="l10"></a></span><span class=cF1>U0</span><span class=cF0> Main()
<a name="l11"></a>{
<a name="l12"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l13"></a> </span><span class=cF2>//This makes all 4 color planes active.</span><span class=cF0>
<a name="l14"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_IDX</span><span class=cF0>,</span><span class=cF3>VGAR_MAP_MASK</span><span class=cF0>);
<a name="l15"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_DATA</span><span class=cF0>,</span><span class=cF3>WHITE</span><span class=cF0>);
<a name="l16"></a> </span><span class=cF5>MemSet</span><span class=cF0>(</span><span class=cFB>text</span><span class=cF0>.vga_alias,0,</span><span class=cF3>GR_WIDTH</span><span class=cF0>*</span><span class=cF3>GR_HEIGHT</span><span class=cF0>/8);
<a name="l17"></a>
<a name="l18"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_IDX</span><span class=cF0>,</span><span class=cF3>VGAR_MAP_MASK</span><span class=cF0>);
<a name="l19"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_DATA</span><span class=cF0>,</span><span class=cF3>RED</span><span class=cF0>);
<a name="l20"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;200;i++)
<a name="l21"></a> PlotXY(i,i);
<a name="l22"></a>
<a name="l23"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_IDX</span><span class=cF0>,</span><span class=cF3>VGAR_MAP_MASK</span><span class=cF0>);
<a name="l24"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_DATA</span><span class=cF0>,</span><span class=cF3>GREEN</span><span class=cF0>);
<a name="l25"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;200;i++)
<a name="l26"></a> PlotXY(100,i);
<a name="l27"></a>
<a name="l28"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_IDX</span><span class=cF0>,</span><span class=cF3>VGAR_MAP_MASK</span><span class=cF0>);
<a name="l29"></a> </span><span class=cF5>OutU8</span><span class=cF0>(</span><span class=cF3>VGAP_DATA</span><span class=cF0>,</span><span class=cF3>BLUE</span><span class=cF0>);
<a name="l30"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;200;i++)
<a name="l31"></a> PlotXY(200-i,i);
<a name="l32"></a></span><span class=cF2>/*If you want a mixed color sel multiple planes</span><span class=cF0>
<a name="l33"></a></span><span class=cF2>but you have to be sure the unseled planes</span><span class=cF0>
<a name="l34"></a></span><span class=cF2>are zero, so sel them and make them zero.</span><span class=cF0>
<a name="l35"></a></span><span class=cF2>You can't do reads on VGA memory, by the way.</span><span class=cF0>
<a name="l36"></a></span><span class=cF2>That means no read-modify-writes, too.</span><span class=cF0>
<a name="l37"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l38"></a> </span><span class=cF5>Busy</span><span class=cF0>(4000000);
<a name="l39"></a>
<a name="l40"></a> </span><span class=cF2>//TempleOS has a 4 plane memory duplicate of the scrn, </span><a href="/Wb/Adam/Gr/GrGlbls.HC.HTML#l3"><span class=cF4>gr.scrn_image</span></a><span class=cF2>,</span><span class=cF0>
<a name="l41"></a> </span><span class=cF2>//and only writes actual changes. See </span><a href="/Wb/Adam/Gr/GrScrn.HC.HTML#l366"><span class=cF4>GrUpdateVGAGraphics</span></a><span class=cF2>().</span><span class=cF0>
<a name="l42"></a> </span><span class=cF2>//&lt;CTRL-ALT-v&gt; will flush scrn VGA cache.</span><span class=cF0>
<a name="l43"></a> </span><span class=cF5>VGAFlush</span><span class=cF0>;
<a name="l44"></a>}
<a name="l45"></a>
<a name="l46"></a>Main;
<a name="l47"></a>
<a name="l48"></a></span><span class=cF2>//See </span><a href="/Wb/Demo/Lectures/GraphicsCPULoad.HC.HTML#l1"><span class=cF4>::/Demo/Lectures/GraphicsCPULoad.HC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l49"></a>
</span></pre></body>
</html>