<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Rami&#039;s Blog</title>
	<atom:link href="http://rojua.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rojua.wordpress.com</link>
	<description>Junk &#38; stuff about Commodore 64 and more</description>
	<lastBuildDate>Tue, 18 May 2010 10:27:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rojua.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Rami&#039;s Blog</title>
		<link>http://rojua.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rojua.wordpress.com/osd.xml" title="Rami&#039;s Blog" />
	<atom:link rel='hub' href='http://rojua.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Screen full of garbace, the C version</title>
		<link>http://rojua.wordpress.com/2010/05/18/screen-full-of-garbace-the-c-version/</link>
		<comments>http://rojua.wordpress.com/2010/05/18/screen-full-of-garbace-the-c-version/#comments</comments>
		<pubDate>Mon, 17 May 2010 22:16:59 +0000</pubDate>
		<dc:creator>ramisaa</dc:creator>
				<category><![CDATA[Commodore64]]></category>

		<guid isPermaLink="false">http://rojua.wordpress.com/?p=76</guid>
		<description><![CDATA[I perhaps did not mention, but I am using DASM for compiling assembler code and cc65 for C code. Below is the the C equivalent of the previous routine. #include "stdio.h" #include "stdlib.h" #define SCREENMEM 0x0400 #define COLORMEM 0xD800 #define RASTER 0xD012 #define KEYBOARDMEM 0xDC01 #define POKE(addr,val) (*(addr) = (val)) #define PEEK(addr) (*(addr)) int main(void) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=76&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I perhaps did not mention, but I am using <a href="http://dasm-dillon.sourceforge.net/">DASM</a> for compiling assembler code and <a href="http://www.cc65.org/">cc65</a> for C code. Below is the the C <a href='http://rojua.files.wordpress.com/2010/05/c-rand.doc'>equivalent</a> of the previous routine.</p>
<p><code><br />
#include "stdio.h"<br />
#include "stdlib.h"</p>
<p>#define SCREENMEM   0x0400<br />
#define COLORMEM  	0xD800<br />
#define RASTER		0xD012<br />
#define KEYBOARDMEM 0xDC01</p>
<p>#define POKE(addr,val) (*(addr) = (val))<br />
#define PEEK(addr) (*(addr))</p>
<p>int main(void) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;int loc = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char ch = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char col = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;_randomize();<br />
&nbsp;&nbsp;&nbsp;&nbsp;while(1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(PEEK((char*)RASTER) == 0x80)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loc = rand() % 1024;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ch = PEEK((char*)(SCREENMEM+loc));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(ch == 0x51)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ch = 0x57;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if(ch == 0x57)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ch = 0x20;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if(ch == 0x2A)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ch = 0x51;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ch = 0x2A;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;col = rand() % 16;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;POKE((char *)(SCREENMEM + loc), ch);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;POKE((char *)(COLORMEM + loc), col);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(PEEK((char*)KEYBOARDMEM) == 0xEF)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;return EXIT_SUCCESS;<br />
}<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rojua.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rojua.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rojua.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rojua.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rojua.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rojua.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rojua.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rojua.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=76&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rojua.wordpress.com/2010/05/18/screen-full-of-garbace-the-c-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4338e11a93abc5c78cab4403563d619?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ramisaa</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding some color to that mess</title>
		<link>http://rojua.wordpress.com/2010/05/15/adding-some-color-to-that-mess/</link>
		<comments>http://rojua.wordpress.com/2010/05/15/adding-some-color-to-that-mess/#comments</comments>
		<pubDate>Sat, 15 May 2010 21:20:10 +0000</pubDate>
		<dc:creator>ramisaa</dc:creator>
				<category><![CDATA[Commodore64]]></category>

		<guid isPermaLink="false">http://rojua.wordpress.com/?p=61</guid>
		<description><![CDATA[OK back to business. Here is a short addition to the previous &#8220;character stars&#8221; program that adds some random colors to it. The new file can be downloaded here. As before, the file suffix has been changed to fool WordPress. The file is plain ascii asm code. So what has changed to the previous routine [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=61&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK back to business. Here is a short addition to the previous &#8220;character stars&#8221; program that adds some random colors to it. The new file can be downloaded <a href='http://rojua.files.wordpress.com/2010/05/color-rand.doc'>here</a>. As before, the file suffix has been changed to fool WordPress. The file is plain ascii asm code. </p>
<p>So what has changed to the previous routine you ask anxiously. Not much actually. First we add some new hard-coded memory locations to the routine just like we did with the screen memory. This is the memory area that defines the color of a specific location on the screen. $D800 (55296) is the address where the color memory starts by default. </p>
<p><code><br />
SCRMEM1		.byte	$00, $04, $FF, $04, $FE, $05, $FF, $06 	; screen memory<br />
COLMEM1		.byte	$00, $D8, $FF, $D8, $FE, $D9, $FF, $DA 	; color memory<br />
</code></p>
<p>Then we modify the TRANSFER routine so that we take up (to zero page addresses $BD &amp; $BE) the screen color address for the same screen location we randomly chose to draw our character to:</p>
<p><code><br />
TRANSFER1<br />
&nbsp;&nbsp;&nbsp;&nbsp;CLC<br />
&nbsp;&nbsp;&nbsp;&nbsp;ROL&nbsp;&nbsp;&nbsp;&nbsp;; get correct screen memory location<br />
&nbsp;&nbsp;&nbsp;&nbsp;TAY<br />
&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp;&nbsp;&nbsp;SCRMEM1,Y&nbsp;&nbsp;&nbsp;&nbsp;;first half of screen address<br />
&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp;&nbsp;&nbsp;$BB<br />
&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp;&nbsp;&nbsp;COLMEM1,Y&nbsp;&nbsp;&nbsp;&nbsp;; first half of color address<br />
&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp;&nbsp;&nbsp;$BD<br />
&nbsp;&nbsp;&nbsp;&nbsp;INY<br />
&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp;&nbsp;&nbsp;SCRMEM1,Y&nbsp;&nbsp;&nbsp;&nbsp;; second half of screen address<br />
&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp;&nbsp;&nbsp;$BC<br />
&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp;&nbsp;&nbsp;COLMEM1,Y&nbsp;&nbsp;&nbsp;&nbsp;; second half of color address<br />
&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp;&nbsp;&nbsp;$BE<br />
&nbsp;&nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp;&nbsp;&nbsp;TAILPART<br />
</code></p>
<p>And finally we add some new lines to the DRAW routine that will eventually draw the character on the screen: </p>
<p><code><br />
DRAW<br />
&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp;&nbsp;&nbsp;($BB),Y&nbsp;&nbsp;&nbsp;&nbsp;; print character<br />
&nbsp;&nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp;&nbsp;&nbsp;RNDBYT<br />
&nbsp;&nbsp;&nbsp;&nbsp;AND&nbsp;&nbsp;&nbsp;&nbsp;#$0F&nbsp;&nbsp;&nbsp;&nbsp;; scale to 0-15<br />
&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp;&nbsp;&nbsp;($BD),Y&nbsp;&nbsp;&nbsp;&nbsp;; store value to color memory<br />
&nbsp;&nbsp;&nbsp;&nbsp;RTS<br />
</code></p>
<p><strong>What next?</strong><br />
I have been looking at cc65 a C-crosscompiler that can generate code for Commodore64. I am most likely to go on creating a simple game using sprites and character graphics either with C or assembly. I am also looking at how to generate high resolution (300&#215;200 pixels) graphics in assembler, but that may take a while. I may also expand this blog to cover some of my beginner electronics projects such as  <a href="http://www.ktverkko.fi/~msmakela/8bit/c2n232/index.en.html">this</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rojua.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rojua.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rojua.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rojua.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rojua.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rojua.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rojua.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rojua.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=61&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rojua.wordpress.com/2010/05/15/adding-some-color-to-that-mess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4338e11a93abc5c78cab4403563d619?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ramisaa</media:title>
		</media:content>
	</item>
		<item>
		<title>Screen full of garbage: random screen location in assembler</title>
		<link>http://rojua.wordpress.com/2009/12/29/screen-full-of-garbage-random-screen-location-in-assembler/</link>
		<comments>http://rojua.wordpress.com/2009/12/29/screen-full-of-garbage-random-screen-location-in-assembler/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 21:44:27 +0000</pubDate>
		<dc:creator>ramisaa</dc:creator>
				<category><![CDATA[Commodore64]]></category>

		<guid isPermaLink="false">http://rojua.wordpress.com/?p=36</guid>
		<description><![CDATA[OK. Time to move on. In previous post I introduced few issues that one has to take into account when programming in Commodore 64 assembler and introduced the assembler version of that lame &#8220;starfield&#8221; routine. Which can be found here. It has &#8220;.doc&#8221; suffix because of WordPress file filters, but it is actually a plain [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=36&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK. Time to move on. In previous post I introduced few issues that one has to take into account when programming in Commodore 64 assembler and introduced the assembler version of that lame &#8220;starfield&#8221; routine. Which can be found <a href="http://rojua.files.wordpress.com/2009/12/sfoc.doc">here</a>. It has &#8220;.doc&#8221; suffix because of WordPress file filters, but it is actually a plain ASCII file. In this  post I will introduce the main routine as well as the routine to get the random screen location where to put the character.</p>
<p><strong>The main routine</strong><br />
<code><br />
MAIN<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;SEI<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RDINIT&nbsp; &nbsp;&nbsp;&nbsp;;init rnd number<br />
WAIT<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RASTER&nbsp; &nbsp;&nbsp;&nbsp;;check for raster line<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$80<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;BNE&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;WAIT&nbsp; &nbsp;&nbsp;&nbsp;;wait if not #$80<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RNDBYT&nbsp; &nbsp;&nbsp;&nbsp;;get rnd number<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;AND&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$03&nbsp; &nbsp;&nbsp;&nbsp;;scale it to range 0-3<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;TRANSFER1<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$DC01&nbsp; &nbsp;&nbsp;&nbsp;;LOAD DATA PORT B / KEYBOARD<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$EF&nbsp; &nbsp;&nbsp;&nbsp;;SPACE<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;BNE&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;WAIT<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CLI<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RTS<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;BRK<br />
</code><br />
The main routine starts with SEI operation that will turn off the system interrupts (try to comment it out and see what happens) and then it will initialize the random number generator routine. Next we will check the raster line, that is, on which screen line the computer is drawing at the moment. We use this to slow down out routine to happen &#8220;only&#8221; 50 times a second. </p>
<p>Then we get a random number (0-255) and &#8220;AND&#8221; it with 3 that will zero all the other bits of the random number except the lowest two bits (giving us the range of 0-3). Finally we call the routine to select the random screen location. </p>
<p><strong>Getting the random screen location</strong><br />
By now we have a routine for 8-bit random numbers (values 0-255), but the screen has 1024 locations starting with  memory location 1024 ($0400) and ending in location 2047 ($07FF). So I split the screen into four 256 byte chunks and stored the start addresses to memory:<br />
<code><br />
SCRMEM1		.byte	$00, $04, $FF, $04, $FE, $05, $FF, $06<br />
</code><br />
Note that the address bytes are wrapped around so $0400 becomes $00, $04. You can actually change the screen memory location, but we&#8217;ll look at that later on.<br />
<code><br />
TRANSFER1<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CLC<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ROL&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;; get correct screen memory location<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;TAY<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;SCRMEM1,Y&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;;first half of screen address<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$BB<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;INY<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;SCRMEM1,Y	; second half of screen address<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$BC<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;TAILPART<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RTS<br />
</code><br />
So the accumulator contains the previous random number (0-3) fetched in the WAIT routine. We clear the carry flag and rotate the number left one bit (I later realized that using the the normal shift operation, ASL). Now we have a even number between 0 and 6 inclusive. We use this value to select the proper chunk of 255 bits of screen memory. </p>
<p>First, we store that value to the Y register so that we can use it to access memory location and then we get the first (low!) byte of the screen address and place it in zero page to location $BB. Then we increase the Y value and get the next byte (the high byte of the memory location) and place it in $BC. Now we have the starting address of one of four screen location chunks in the $BB-$BC memory location. Next we call the &#8220;TAILPART&#8221; routine. </p>
<p><strong>Select and print out a character in given location</strong><br />
<code><br />
TAILPART				; check and print the character<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JSR&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RNDBYT<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;TAY<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;($BB),Y		; load curren character at $BB+1<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$51		; if it is ball<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;BEQ&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;STEP2<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$57		; if it is donut<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;BEQ&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;STEP0<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$2A		; if it is asterisk<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;BEQ&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;STEP1<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$2A		; else<br />
DRAW<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;STA &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ($BB),Y		; print character<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RTS<br />
STEP0<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$20		; space<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DRAW<br />
STEP1<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #$51		; ball<br />
 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DRAW<br />
STEP2<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#$57		; donut<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;JMP&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DRAW<br />
</code></p>
<p>First we get yet another random number. This one defines the actual screen location which we use to store our character, but before that we will read the contents (character) of the same memory location:</p>
<ul>
<li>If the character is ball we will replace it with donut.</li>
<li>If it is donut we will replace it with a space</li>
<li>If it is asterisk we will replace it with ball</li>
<li>Otherwise we will insert asterisk in the screen location.</li>
</ul>
<p>And then in the DRAW routine we will put the selected character to the selected screen location (we take the address stored in address $BB-$BC, add Y to it and store the accumulator in that memory location).</p>
<p>Finally we return (RTS) back to the TRANSFER1 routine and again return back to the WAIT routine where we will check if space key has been pressed. If not, we do the thing all over again. If space has been pressed we will enable interrupts and exit our program. </p>
<p>That&#8217;s about it. Next time we will add some colors to this routine.   </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rojua.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rojua.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rojua.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rojua.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rojua.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rojua.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rojua.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rojua.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=36&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rojua.wordpress.com/2009/12/29/screen-full-of-garbage-random-screen-location-in-assembler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4338e11a93abc5c78cab4403563d619?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ramisaa</media:title>
		</media:content>
	</item>
		<item>
		<title>Screen full of garbage, enter confusion</title>
		<link>http://rojua.wordpress.com/2009/11/25/screen-full-of-garbage-enter-confusion/</link>
		<comments>http://rojua.wordpress.com/2009/11/25/screen-full-of-garbage-enter-confusion/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 22:41:36 +0000</pubDate>
		<dc:creator>ramisaa</dc:creator>
				<category><![CDATA[Commodore64]]></category>

		<guid isPermaLink="false">http://rojua.wordpress.com/?p=12</guid>
		<description><![CDATA[Screen full of garbage. Initial feelings about 6502 assembler. I'll also dive to the random number generator routine. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=12&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I started to learn 6502 assembly language. It is not my first assembler to dabble with: I&#8217;ve been doing some small exercises in Mips assembler (largest program&nbsp; was a merge sort algorithm). But &#8211; oh boy &#8211; was I about to face some serious issues.</p>
<p><strong>Data size</strong></p>
<p>8-bit computers surprisingly deal with data in bytes. The registers are byte sized along with the other stuff. So what does it mean? Basically you can freely do stuff with numbers between 0-255, but after that it gets a bit more complicated. Now, 255 is awfully small number if you are about to, for example, multiply a number with another (not to mention the floating point numbers or the BCD format of which I may dabble with later). Even more so if you have been used to use variables like 32 bit integers without thinking it much. Which brings us to the</p>
<p><strong>Instruction set</strong></p>
<p>Oh dear<strong>, </strong>the instruction set is very small and lacks such novelty things like multiplication. And there is (to my knowledge) no available kernel routine for that (perhaps one could use the Basic multiplication routine?).&nbsp; So it pretty much looks like one has to do all the boring things first. Maybe my coworker is kind enough to let me to put his &#8220;print number&#8221; and multiplication routines in this blog at some point.</p>
<p><strong>Registers</strong></p>
<p>You have three of them: accumulator, X and Y and thats about it. Be prepared to swap things around quite a bit. There is also the program stack of which we will have closer look after this set of blogs.</p>
<p><strong>Memory</strong></p>
<p>Where the processor and registers work in 8 bit chunks, the memory address is a 16 bit number. Actually, a wrapped around one so if you want to point to the location $0c00 then you put the low byte first: $oo $0c. With all the other things this just nicely adds up to the initial confusion.<br />
It is also quite hard to start programming a system that relies in the use of various memory locations (or routines residing in certain memory addresses) while you only know a handful of the system addresses.</p>
<p><strong>Something good too!</strong></p>
<p>But in the end I have to admire the simplicity, elegance and openness of the system. No wonder it has been the favorite of many modders and DIY dudes all around the world. And even though the first steps has been as comfortable as sitting on the ant&#8217;s nest with no pants on, I have some unexplained need to continue with learning and trying out various silly things with the assembler.</p>
<p>Anyway, here is the full source code of the assembler routine: <a href='http://rojua.files.wordpress.com/2009/12/sfoc.doc'>sfoc2</a>. It is a plain text file, the &#8220;doc&#8221; suffix is because of the file filter of WordPress. I&#8217;ll (try to) dissect the code in the following posts.</p>
<p><strong>The random number generator</strong></p>
<p>Lets start with random numbers instead of doing my own <a href="http://www.6502.org/source/integers/random/random.html">&#8220;linear congruential random number&#8221; generation routine</a> I just copied one I found from the Compute&#8217;s book &#8220;Machine language routines for Commodore 64/128 &#8220;. The name of the routine is RNDDBYT:</p>
<p><code><br />
RDINIT&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; init rnd from the sound chip<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;#$FF<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp; &nbsp;FREHI3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;#%10000000<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp; &nbsp;VCREG3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STA&nbsp;&nbsp; &nbsp;SIGVOL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RTS<br />
RNDBYT<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LDA&nbsp;&nbsp; &nbsp;RANDOM&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;; get random number<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RTS<br />
</code><br />
The RDINIT routine is called just once to set up the random number generator.</p>
<ul>
<li>First the number 255 is put to the accumulator and then stored to FREHI3 ($D40F,  54287) which is the high byte of frequency control for voice 3 in SID changing the voice&#8217;s wave frequency to very high.</li>
<li>Then the number 128 (8th bit) is loaded to accumulator and it is used to set the voice 3 waveform type to noise (VCREG3, see for example the Commodore 64 user&#8217;s guide for more information).</li>
<li>And finally the same 128 is used to set up the volume of voice 3 making it inaudible. The maximum volume is 15 so I guess making the number go over the limit will turn volume off?</li>
</ul>
<p>The RNDBYT routine just copies the value from the &#8220;third oscillator&#8217;s waveform&#8221; whatever that means (probably it is the current value of the voice 3 waveform and since it is rabidly changing noise it will work as random number generator).</p>
<p>Funnily enough the routine RDBYRG in the same book gets the random number in given range (0-255) by <em>reading the oscillator waveform until it gets the number within the given range</em>!! This is almost as good as <a href="http://en.wikipedia.org/wiki/Bogosort">Bogosort</a>. </p>
<p>Next time we will be back, the blog will talk about getting a random location from screen. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rojua.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rojua.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rojua.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rojua.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rojua.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rojua.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rojua.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rojua.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=12&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rojua.wordpress.com/2009/11/25/screen-full-of-garbage-enter-confusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4338e11a93abc5c78cab4403563d619?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ramisaa</media:title>
		</media:content>
	</item>
		<item>
		<title>Screen full of garbage, basic version</title>
		<link>http://rojua.wordpress.com/2009/11/19/screen-full-of-garbage-basic-version/</link>
		<comments>http://rojua.wordpress.com/2009/11/19/screen-full-of-garbage-basic-version/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 14:37:47 +0000</pubDate>
		<dc:creator>ramisaa</dc:creator>
				<category><![CDATA[Commodore64]]></category>

		<guid isPermaLink="false">http://rojua.wordpress.com/?p=4</guid>
		<description><![CDATA[Commodore 64 programming. Basic version of the "starfield" routine.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=4&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong><br />
Some weeks ago I got together with a coworker and we got interested in modding my poor old Commodore 64 computer. We are currently building an interface between the C64 and PC so that the computers can communicate via the cassette port. In fact, C64 does think that it is loading a program from a tape instead of another computer. This way there is no need to make modifications to the Commodore 64.</p>
<p>This has also brought up the interest to learn the Commodore 64 assembly language, a skill I never learned as a kid. All those LDAs and STAs were too much for me at the time and I played games and coded in Basic instead.</p>
<p>So few weeks ago I started to look at programming the good old Commodore 64 and found out that my Basic skills had pretty much dried away. I remember being rather good with Basic, but after reading the manuals I started to wonder how much of my Basic coding was just dumb copy-paste instead of really understanding the inner workings of the language and system.</p>
<p>After fiddling for a while I decided to start learning the assembly language. I decided to use Dasm cross-assembler so that I can write the code in some adequate editor and then cross-compile the code to be run either in emulator or in  real C64. I decided to start with a lousy &#8220;star-field&#8221; program that just fills the screen with some characters. In this post I will do an autopsy to the Basic version of the program and then move on to the assembler version in the future posts.</p>
<div id="attachment_5" class="wp-caption aligncenter" style="width: 410px"><a href="http://rojua.files.wordpress.com/2009/11/stars1.png"><img class="size-full wp-image-5" title="stars1" src="http://rojua.files.wordpress.com/2009/11/stars1-e1258640677586.png?w=468" alt=" &quot;Stars&quot;"   /></a><p class="wp-caption-text">&quot;Fancy&quot; star effect aka. screen full of ...</p></div>
<p><strong>The Basic version</strong></p>
<p>10 print chr$(147)<br />
20 x = (rnd(0)*1023)+1024<br />
30 x = (rnd(x)*1023)+1024<br />
40 y = 32<br />
50 ch = peek(x)<br />
60 if ch=42 then y=81<br />
70 if ch=81 then y=87<br />
80 if ch=32 then y=42<br />
90 poke x,y<br />
100 get i$<br />
110 if i$&lt;&gt;&#8221;" then stop<br />
120 goto 30</p>
<p>Line 10 clears the screen.</p>
<p>Line 20 gets a random number between 1024 and 2047 using the internal clock (or some such) as the seed.</p>
<p>Line 30 does the same, but uses the previous random number as the seed. If I would comment out this line, the characters would come up in steady columns like in Matrix (not really, but you get the idea). Such a good random number generator.</p>
<p>Why 1024-2047? As it happens the screen resides in memory locations 1024-2047 and we use this random number to display a character in certain location. For example &#8220;POKE 1024,81&#8243; would display a &#8220;ball&#8221; in the upper left corner of the screen.</p>
<p>Line 40 puts value 32 (space) to variable &#8220;y&#8221; which we use later on to display stuff on screen.</p>
<p>Line 50 looks at the current character in given location (where our random number points to).</p>
<p>lines 60 to 80 just compare the read value so that if it is</p>
<ul>
<li>asterisk (42), then put 81 (ball) to variable &#8220;y&#8221;</li>
<li>a ball (81), then put &#8220;a donut&#8221; (87) to variable &#8220;y&#8221;</li>
<li>a space (32), then put an asterisk (42) to variable &#8220;y&#8221;</li>
<li>otherwise retain the old value of 32 in variable &#8220;y&#8221;</li>
</ul>
<p>Line 90 does all the work and puts the character in variable &#8220;y&#8221; to the random screen location &#8220;x&#8221;.</p>
<p>Line 100 reads user input (one keypress).</p>
<p>Line 110 checks it any key was pressed, if so then stop the program execution.</p>
<p>Otherwise in line 120 jump back to the line 30 and start over again (without clearing the screen, of course).</p>
<p>Looks pretty easy, right?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rojua.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rojua.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rojua.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rojua.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rojua.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rojua.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rojua.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rojua.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rojua.wordpress.com&amp;blog=10578233&amp;post=4&amp;subd=rojua&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rojua.wordpress.com/2009/11/19/screen-full-of-garbage-basic-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a4338e11a93abc5c78cab4403563d619?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ramisaa</media:title>
		</media:content>

		<media:content url="http://rojua.files.wordpress.com/2009/11/stars1-e1258640677586.png" medium="image">
			<media:title type="html">stars1</media:title>
		</media:content>
	</item>
	</channel>
</rss>
