Merhaba, Ziyaretçi. Lütfen giriş yapın veya üye olun.

Kullanıcı adınızı, parolanızı ve aktif kalma süresini giriniz

  Gelişmiş Arama
insanın içinde varsa, commodore.gen.tr açığa çıkarır bunu.. bir nevi retro olaylarının dolunayıyız.(Arda)
commodore.gen.trCommodoreCommodore Genel10 PRINT Kitabı ve CHR$(205.5+RND(1)) Fenomeni
Sayfa: [1]   Aşağı git
Yazdır
Gönderen Konu: 10 PRINT Kitabı ve CHR$(205.5+RND(1)) Fenomeni  (Okunma Sayısı 6243 defa)
0 Üye ve 1 Ziyaretçi konuyu incelemekte.
LW3D
Yönetici
*****
Mesaj Sayısı: 11.269


Günü Kurtaran Avam Hiooargggh :)


Üyelik Bilgileri WWW
« : Şubat 12, 2014, 11:52:37 ÖÖ »

Commodore64 Bilgisayarında aşağıdaki 1 satırlık kodu yazdığınız zaman, labirenti andıran rastlantısal bir desen ortaya çıkıyor... Eskiden karakter setini kullanarak dalga vs. şeyler çıkarır, mutlu olurduk. Ama böylesini hiç görmemiştim (Mustafa Tufan arkadaşımızın paylaşımıdır)

10 PRINT CHR$(205.5+RND(1)); : GOTO 10



Bu fenomenin kaynağıda 10 PRINT adlı kitap sanırım. Amazon.com'da satışta, ama meraklıları için PDF olarakta paylaşılmış... Kitapta sadece bu kodu ele almakla kalmayıp, farklı desenlerin çıkması için gerekli düzenlemeler ve kodlarda paylaşılmış..


http://trope-tank.mit.edu/10_PRINT_121114.pdf
Logged

Devastator
Uzman
*****
Mesaj Sayısı: 1.313

Ziyaretçi


Üyelik Bilgileri
« Yanıtla #1 : Şubat 12, 2014, 12:00:06 ÖS »

Demekki RND' nin algoritması pek de randomization değil. Kesin bir değer hesaplama algoritması olabilir.
Logged
LW3D
Yönetici
*****
Mesaj Sayısı: 11.269


Günü Kurtaran Avam Hiooargggh :)


Üyelik Bilgileri WWW
« Yanıtla #2 : Şubat 12, 2014, 12:14:26 ÖS »

Mustafa Tufan'ın konuyla ilgili açıklaması şöyle...

rnd floating point dönüyor, o yüzden olasiliklari eşitlemek icin .5 var.

205.5 + 0.0-0.4 = 205
205.5 + 0.5-0.9 = 206

Karakter kodu olarak 205 ╲  ve 206'da ╱  Bu ikisi bütün pattern'i ortaya çıkarıyor ve çokta güzel oluyor doğrusu... Kitapta başkalarıda var... Çok güzelmiş..

Logged

wizofwor
Genel Yönetici
*****
Mesaj Sayısı: 4.613


Gosub ile gidilen yerden goto ile dönen adam


Üyelik Bilgileri WWW
« Yanıtla #3 : Şubat 12, 2014, 12:21:20 ÖS »

Dijital olarak random sayı üretmek imkansız. Bilgisayarların ürettiği rastlantısal sayılara bu yüzden psedö-random deniyor. Her hangi bir programlama dilinde daha random sayılar üreten algoritmalar bulabilirsiniz. Commodore64 de istisna değil.

Ama eğer kendi RND rutininizi yazmaya niyetlenirseniz. SID'e random değer ürettiren rutinler var. Kendisi analog bir chip olduğu için bu işte çok daha başarılı.

Sağol LW3D. Bu desene benzeyen şeyleri, labirent çizen kodlar vs. görmüştüm ama konuyu detaylı inceleyecek vaktim olmamıştı. Demek olay RND imiş.
« Son Düzenleme: Şubat 12, 2014, 12:23:16 ÖS Gönderen: wizofwor » Logged

AmigaFUN
Deneyimli
*****
Mesaj Sayısı: 1.157


MC68060 inside!


Üyelik Bilgileri
« Yanıtla #4 : Şubat 12, 2014, 21:24:21 ÖS »

Kendisi analog bir chip olduğu için bu işte çok daha başarılı.


bunu biraz açar mısınız?
Logged

Amiga1200:)
Simon (Özay Turay)
Yönetici
*****
Mesaj Sayısı: 7.306


Commodore Forever


Üyelik Bilgileri WWW
« Yanıtla #5 : Şubat 12, 2014, 23:55:57 ÖS »

Alıntı
SID's Random Number Generator
The 64's SID chip also has the ability to generate random values and is very easy to use. All you need to do is select the noise waveform for the SID's voice 3 oscillator and set voice 3's frequency to some nonzero value (the higher the frequency, the faster the random numbers are generated). It is not necessary to gate (turn on) the voice. Once this is done, random values appear in location $D41B. The parameters need only be set once, as shown in this example. (You'll need a machine language assembler to enter this and the following example; the semicolons and the comments which follow them are optional.)

LDA #$FF  ; maximum frequency value
STA $D40E ; voice 3 frequency low byte
STA $D40F ; voice 3 frequency high byte
LDA #$80  ; noise waveform, gate bit off
STA $D412 ; voice 3 control register
RTS

    Once this code is executed, the SID chip continuously produces random byte values, which you can retrieve with a statement like LDA $D41B. This method works only on the Commodore 64 and 128, since only those two computers have a SID chip. Values obtained from the SID chip do seem to be random: Each of the values in the range 0-255 occurs at about the same frequency, and the series does not repeat in the first 34,000 values.
    In many cases, you'll want to obtain random numbers only within a certain range. In BASIC, this is done with a statement like RND (1)*(U-L)+L. Here the variables U and L stand for the upper and lower limits, respectively, of the number range we want. This statement produces integer numbers within that range, excluding the first and last values in the range (for instance, if U=30 and L=1, then 30 and 1 do not appear in the series). To include the first and last values, use a statement like INT (RND(1)*(U-L+1)+L.
    In machine language, we're usually interested in single byte values: integers in the range 0-255. Should larger values be needed, you can always generate two or more bytes and combine them. Getting numbers within a certain range is simply a matter of generating numbers until you find one that falls in the range you want. For instance, the following routine generates numbers within the range $10-$40 (before performing this routine, you must set up the SID chip as shown above):

RAND LDA $D41B ; get random value
                from 0-255
     CMP #$31  ; compare to
                 U-L+1
               ; U-L+1 = $31 =
                $40-$10+$01
     BCS RAND   ; branch if value >
                U-L+1
     ADC #$10  ; add L
     RTS

    This routine generates random numbers until one is found that falls between 0 and the difference between the high and low values. Then the low value is added to the result to give a value between the low and high limits, inclusive. If the range is very small, many numbers may have to be generated before you find one that's suitable.
    You can decrease the delay by ANDing the random number with a value that removes the unwanted higher bits. For instance, if the difference between the low and high limits is $0A, then AND the random value with $0F to remove the four high bits, then test whether it falls within the range. One useful special case deserves mention. To generate an integer in the range -1 to 1 inclusive, use the BASIC statement INT(RND(1)*3)-1. To get a value between $01 and $FF in machine language, AND the random value with $03 and use a routine like the one shown above, where L=$FF and U-L+1=$03.
    The method you use to generate random numbers depends on your needs. In machine language, if repeatable values aren't needed, it's simplest to use the SID chip. Should repeatable values be required (for testing a routine, etc.), set the chosen seed in the seed locations $8B-$8F, call the ROM routine at $E0BE, then use the value found in locations $63 or $64 for the random number. Due to its questionable randomness, the timer/ clock method is not recommended.


Alıntı: http://www.atarimagazines.com/compute/issue72/random_numbers.php

http://www.mos6502.com/friday-commodore/random-numbers-electronic-dice-and-the-c64/

Ayrıca şurada da Random Numbers başlığı altında farklı metodlar mevcut: http://codebase64.org/doku.php?id=base:6502_6510_maths

Bir de resimdeki C fonksiyonu var. İşini görür mü bilemem. Kahkaha


* random_number.png (7.28 KB, 400x144 - Görüntüleme: 1461 kez.)
Logged

http://www.retrodergi.com - http://www.e-turay.com - http://www.karizmawow.com

Retro: Commodore 64, Amiga 500, Amiga 1200
Retromsu: Wii, XBox360, XBox, PS3 Slim, PS2 FAT, PS1, PS Vita, Nintendo 3DS, Nintendo 2DS
wizofwor
Genel Yönetici
*****
Mesaj Sayısı: 4.613


Gosub ile gidilen yerden goto ile dönen adam


Üyelik Bilgileri WWW
« Yanıtla #6 : Şubat 13, 2014, 00:02:23 ÖÖ »

SID çipi tamamen dijital yapıda değil. Kontrol yapıları dijitalken sesi üreten kısımlar analog yapıdadır. Hatta bu analog komponentler bire bir aynı olmadığı için her çipin ürettiği ses az da olsa farklıdır. Yine emulatörlerin SID chiptune'ların 100% doğru çalamaması da bu analog yapıdan kaynaklanır.

Random olayı da noise waweform kullanılarak yapılıyor. Simon'un yapıştırdığı metinde örnek kod var.

Basic random rutini use CIA timerlarını ve bir lookup table kullanarak çalışıyor.
  
Logged

AmigaFUN
Deneyimli
*****
Mesaj Sayısı: 1.157


MC68060 inside!


Üyelik Bilgileri
« Yanıtla #7 : Şubat 13, 2014, 00:12:42 ÖÖ »

guzel bilgiler... tesekkurler, okuyalim biraz... ama yine de sonda soracagim soruyu bastan sorayim: sonucta ortada bir algoritma var/olacak , seri bir yerden sonra tekrarlar önermesi doğru mudur?
Logged

Amiga1200:)
wizofwor
Genel Yönetici
*****
Mesaj Sayısı: 4.613


Gosub ile gidilen yerden goto ile dönen adam


Üyelik Bilgileri WWW
« Yanıtla #8 : Şubat 13, 2014, 08:31:10 ÖÖ »

İşte internetin ve bilgi çağının faydaları. SID'in ürettiği random da aslında o kadar random değilmiş. Bazı kaynaklarda SID TDG (True Random Generator) olarak geçiyor ama aslında ürettiği noise formu belirli bir desen izliyor. Reverse engineering metodlarıyla incelendiğinde noise formu için gereken veriyi bir LFSR devresinin ürettiğini bulmuşlar. Bu da durumu fazlasıyla açıklıyor.

Böylelikle kendimi de yalanlamış oldum ama SID'in ürettiği random'un Basic rutininden pek de farkı yokmuş.
Logged

Simon (Özay Turay)
Yönetici
*****
Mesaj Sayısı: 7.306


Commodore Forever


Üyelik Bilgileri WWW
« Yanıtla #9 : Şubat 20, 2023, 10:36:21 ÖÖ »

Bunun 3D versiyonu yapılmış. Kahkaha

https://www.youtube.com/watch?v=VC-lbd8mTOs
Logged

http://www.retrodergi.com - http://www.e-turay.com - http://www.karizmawow.com

Retro: Commodore 64, Amiga 500, Amiga 1200
Retromsu: Wii, XBox360, XBox, PS3 Slim, PS2 FAT, PS1, PS Vita, Nintendo 3DS, Nintendo 2DS
fort_apocalypse
Uzman
*****
Mesaj Sayısı: 3.440



Üyelik Bilgileri WWW
« Yanıtla #10 : Şubat 20, 2023, 10:55:24 ÖÖ »

Bunun 3D versiyonu yapılmış. Kahkaha

https://www.youtube.com/watch?v=VC-lbd8mTOs

Nerdeyse 40 yıldır kullanılıyor ve hala yeni birşeyler yapılıyor.
Logged

witchdoktor
Uzman
*****
Mesaj Sayısı: 6.236



Üyelik Bilgileri
« Yanıtla #11 : Şubat 20, 2023, 11:27:16 ÖÖ »

Bunun 3D versiyonu yapılmış. Kahkaha

https://www.youtube.com/watch?v=VC-lbd8mTOs

Güzelmiş...

Orijinal koda ait kitabın okuması da keyiflidir.

https://10print.org/10_PRINT_121114.pdf
Logged
Sayfa: [1]   Yukarı git
Yazdır
Gitmek istediğiniz yer: