суббота, 30 марта 2013 г.

I love this blog very much.

http://atariaction.tumblr.com/post/37174168567/day-1-getting-started-with-action
 
Kevin Savetz is a very good man trying to say us that there are MUCH more ways to think in a computer way than evidently posessed.

I'm trying only the next one attempt.
Seriously the reason to wrighting something here is my impression of his blog.

When I tried to convert ACTION! program to PL65 I've ran into the first problem...
There was no function in PL65 returning random value between 0 and 1.

So, it's my duty.

The Code:

FUNC RAND()
  CONST RANDOM=$D20A
  BYTE B
BEGIN
  B=PEEK(RANDOM)
  IF B>127 THEN B=1 ELSE B=0 ENDIF
END B


Here we get semirandom value from HW RANDOM register and as we know that it's between 0..255 then we set a border for making choice. 127 is a right value.

And the code of full program:

INCLUDE D8:TERMINAL.LIB
INCLUDE D8:PEEKPOKE.LIB

  INT X

FUNC RAND()
  CONST RANDOM=$D20A
  BYTE B
BEGIN
  B=PEEK(RANDOM)
  IF B>127 THEN B=1 ELSE B=0 ENDIF
END B

MAIN()
  BYTE B
BEGIN
  POKE(82,0)
  WRTSTR("GO") CR()

  REPEAT
    X=(6+RAND())
    PUT(0,X)
  UNTIL PEEK(764)=28
END


Here is TERMINAL - for I/O
PEEKPOKE - for ..?
Hmm! Peek and Poke!

And at last It's work!

Комментариев нет:

Отправить комментарий