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)
Sayfa: [1]   Aşağı git
Yazdır
Gönderen Konu: ccz80 dili  (Okunma Sayısı 9651 defa)
0 Üye ve 1 Ziyaretçi konuyu incelemekte.
Alcofribas
Uzman
*****
Mesaj Sayısı: 986


Who Dares Wins!


Üyelik Bilgileri
« : Ocak 24, 2008, 01:18:18 ÖÖ »

   Z80 işlemci kullanan bilgisayarlar için, C sözdizimi tabanlı yeni bir dil olan ccz80 duyuruldu. Komut satırında çalışan derleyici; ccz80 dilinde yazılmış bir koddan, Assembler'da binary çalışır dosya haline getirmek üzere bir ASM kodu üretiyor. Daha sonra bu ASM kodunu ister gerçek bir bilgisayarda isterseniz bir emülatörde kullanabilirsiniz.

   Şu an için Standart kütüphane haricinde Spectrum, Amstrad CPC 464 ve CPC 6128 kütüphaneleri mevcut. Bu derleyici ücretsizdir ancak kodu açık değildir.

   Nasıl kullanılacağı sitesinde gayet detaylı anlatılıyorsa da, biz Amstrad CPC'de test etmiş olduğum yöntemi adım adım görelim:

   1-İlgili dosyaları ve fazlasını şu siteden veya şundan indirin.

               Şu an elzem olan dosyalar   
      * ccz80 compiler
      * ccz80 standard library
      * Amstrad CPC 464 library
      * Amstrad CPC 6128 library
   
               Diğerleri
      * ccz80 language and standard library documentation   
      * Amstrad CPC 6128 libraries documentation
      * Word file with ccz80 syntax for UltraEdit
      * Spectrum library
      * Spectrum library documentation
      * Pasmo Cross Assembler olarak tavsiye ediliyor. (eğer emülatörünüzde yoksa)

   2-Bir klasör açın ve içine "ccz80.exe", "standard.ccz80" ve "Amstrad library cpc464.ccz80" dosyalarını zip klasörlerinden çıkararak kopyalayın.
   
   3-Notepad'da yine aynı klasör içine test isminde(başka birşey de olabilir) bir txt dosyası oluşturun ve içine şu kodu yapıştırın:
Kod:
		include "cpc464.ccz80"; // Use de Amstrad library
byte i = 32; // Declare a byte variable and initialize it with 32
repeat (224) // Loop of 224 pass
printc(i++); // Call to printc function (included in cpc464.ccz80 library) and post-increment the i variable
return; // Ends program an return to BASIC
   4-Windows'da Başlat/Çalıştır'dan (Start/Run) cmd komutunu vererek komut satırına geçin. Cd komutunu ve doğru yolu vererek oluşturduğunuz klasörün içine girin.
       
   5-Klasörün içinde iseniz şu satırı yazın:
Kod:
		ccz80 program.ccz80 /org=#A000
   6-Herhangi bir hata yoksa şu anda çalışma klasörünüz içinde test.asm isimli bir dosya oluşmuş olması lazım.

   7-WinApe emülatörünü çalıştırın ve F3'e basarak Assembler ekranına geçin. File/Open ile test.asm dosyasını yükleyin ve Ctrl+F9 ile kodunuzu Assemble edin.

   8-Emülatör ekranına dönün ve CALL &A000 komutunu verin. Sürpriz olmasa bile sonucu seyredin
Logged

LW3D
Yönetici
*****
Mesaj Sayısı: 11.418


Günü Kurtaran Avam Hiooargggh :)


Üyelik Bilgileri WWW
« Yanıtla #1 : Ocak 24, 2008, 19:05:28 ÖS »

Ellerine sağlık Alcofribas,

pek kimsenin ilgisini çekmiş gibi görünmesede, böyle derli toplu, bir makale tadında mesajlarına hayran olmamak elde değil... Çok teşekkürler...
Logged

Alcofribas
Uzman
*****
Mesaj Sayısı: 986


Who Dares Wins!


Üyelik Bilgileri
« Yanıtla #2 : Ocak 26, 2008, 15:21:52 ÖS »

ccz80 IDE yayınlandı. Tanıtım yazısında bahsetmiş olduğumuz edit, compile, assembler, convert işlemleri de artık kolaylaşmış oldu.

Visual Basic .NET ile geliştirilmiş ve Microsoft .NET kütüphanesine ihtiyaç duyuyor.

* ccz80 IDE
* ccz80 IDE documentation
Logged

LW3D
Yönetici
*****
Mesaj Sayısı: 11.418


Günü Kurtaran Avam Hiooargggh :)


Üyelik Bilgileri WWW
« Yanıtla #3 : Ocak 26, 2008, 15:23:57 ÖS »

Çılgın bunlar Hakikaten helal olsun.
Logged

Alcofribas
Uzman
*****
Mesaj Sayısı: 986


Who Dares Wins!


Üyelik Bilgileri
« Yanıtla #4 : Ocak 26, 2008, 15:31:38 ÖS »

Çılgın bunlar Hakikaten helal olsun.

Hep diyorum ya; bu fransızlar ve ispanyollar retro olayını damarlarına kadar yaşıyorlar, yaşatıyorlar. Her biri birer "Vigo + Nightlord" karışımı gücünde...
Logged

Alcofribas
Uzman
*****
Mesaj Sayısı: 986


Who Dares Wins!


Üyelik Bilgileri
« Yanıtla #5 : Ocak 26, 2008, 15:55:10 ÖS »

Örnek Kod olarak "Oh Mummy 2!" oyunu ve buna ait resim kütüphanesi aşağıdadır. #4000'dan itibaren derleyin.

Oh Mummy 2!


Kod:
// Oh Mummy 2!
// Well, it's a little tribute to that great game

include "cpc464.ccz80", "CPC_image.ccz80";

// Data sprite
array byte sprite_man_left_stop = { 0, 0, 0, 0, 0, 7, 14, 0, 3, 15, 15, 0, 0, 190, 135, 0,
                                    51, 255, 224, 0, 0, 191, 134, 0, 0, 103, 120, 0, 0, 7, 60, 128,
                                    0, 159, 240, 128, 0, 191, 233, 0, 0, 23, 15, 0, 0, 3, 14, 0,
                                    0, 3, 12, 0, 0, 3, 12, 0, 0, 51, 204, 0, 0, 119, 204, 0 },
           sprite_man_left_move = { 0, 0, 0, 0, 0, 7, 14, 0, 3, 15, 15, 0, 0, 190, 135, 0,
                                    51, 255, 224, 0, 0, 191, 134, 0, 0, 103, 120, 0, 0, 7, 240, 0,
                                    51, 240, 225, 0, 51, 240, 195, 0, 0, 13, 15, 8, 1, 14, 15, 12,
                                    1, 15, 7, 76, 3, 14, 3, 238, 51, 204, 17, 204, 119, 204, 51, 136 },
           sprite_man_right_stop = { 0, 0, 0, 0, 0, 7, 14, 0, 0, 15, 15, 12, 0, 30, 215, 0,
                                     0, 112, 255, 204, 0, 22, 223, 0, 0, 225, 110, 0, 16, 195, 14, 0,
                                     16, 240, 159, 0, 0, 121, 223, 0, 0, 15, 142, 0, 0, 7, 12, 0,
                                     0, 3, 12, 0, 0, 3, 12, 0, 0, 51, 204, 0, 0, 51, 238, 0 },
           sprite_man_right_move = { 0, 0, 0, 0, 0, 7, 14, 0, 0, 15, 15, 12, 0, 30, 215, 0,
                                     0, 112, 255, 204, 0, 22, 223, 0, 0, 225, 110, 0, 0, 240, 14, 0,
                                     0, 120, 240, 204, 0, 60, 240, 204, 1, 15, 11, 0, 3, 15, 7, 8,
                                     35, 14, 15, 8, 119, 12, 7, 12, 51, 136, 51, 204, 17, 204, 51, 238 },
           sprite_mummy_left = { 0, 0, 0, 0, 0, 16, 192, 0, 0, 48, 224, 0, 0, 48, 224, 0,
                                 0, 48, 192, 0, 0, 16, 224, 0, 16, 240, 224, 0, 48, 240, 160, 0,
                                 48, 32, 224, 0, 0, 48, 224, 0, 0, 48, 224, 0, 0, 48, 240, 0,
                                 0, 112, 112, 0, 0, 112, 48, 128, 0, 224, 48, 128, 16, 224, 112, 128 },
           sprite_mummy_right = { 0, 0, 0, 0, 0, 48, 128, 0, 0, 112, 192, 0, 0, 112, 192, 0,
                                  0, 48, 192, 0, 0, 112, 128, 0, 0, 112, 240, 128, 0, 80, 240, 192,
                                  0, 112, 64, 192, 0, 112, 192, 0, 0, 112, 192, 0, 0, 240, 192, 0,
                                  0, 224, 224, 0, 16, 192, 224, 0, 16, 192, 112, 0, 16, 224, 112, 128 };

// Program variables
byte i, n, n1, n2, c;
byte x_man, y_man, step_man, x_man_prev, y_man_prev, lives, score, alive; // Man variables
byte x_stone, y_stone; // Rock variables
byte x_exit, y_exit; // Screen variables
word p, q, s;
array byte background_man[64]; // Background man buffer
array byte music_block[13]; // Music timer buffer


gosub Initialization; // Global initialization
locate(1,1); printc(253);

while (1) // Main loop
{
  gosub Presentation;
  gosub InitializeGame; // Game initialization

  while (lives)
  {
    gosub InitializeScreen; // Current screen initialization

      q = notes;
      every(12, PlayMusic, music_block); // Initialize music

    while (alive && !(x_man == x_exit && y_man == y_exit))
    {
      repeat (4) frame(); // For reduce game speed

      // Evaluate man moving
      if (*char_address(x_man, y_man + 2) == 0 && *char_address(x_man + 1, y_man + 2) == 0) // Under man is nothing
      {
        ++y_man;
      }
      else
      {
         if (testkey(67) != -1 && y_man > 3 && *char_address(x_man, y_man - 1) == 0 && *char_address(x_man + 1, y_man - 1) == 0) // Jump
        {
          --y_man;
        }

         if (testkey(34) != -1 && x_man > 1 && *char_address(x_man - 1, y_man) == 0 && *char_address(x_man - 1, y_man + 1) == 0) // Left
        {
          --x_man;
          step_man = 0;
        }

         if (testkey(27) != -1 && x_man < 39 && *char_address(x_man + 2, y_man) == 0 && *char_address(x_man + 2, y_man + 1) == 0) // Right
        {
          ++x_man;
          step_man = 1;
        }
      }

      gosub TestManMoved;

      // Move stone or create new
      if (y_stone) // Stone is falling
      {
        ++y_stone;
        if (((x_stone == x_man || x_stone == x_man + 1) && y_stone == y_man) || testkey(66) != -1) // Lost live
        {
          alive = 0;
          for (s = 500; s <= 2000; s += 500) sound(2, s, 25, 15, 0, 0, 0); // Sound for lost

          for (i = 1; i <= 2; ++i)
          {
            locate(2 * lives + 29, i);
            printc(18); // Erase man of screen top
          }
          --lives;

          if (lives)
          {
            pen(1);
            locate(7, 12);
            prints("Press SPACE to continue ...");
            while (testkey(47) == -1);
          }
        }
        else if (*char_address(x_stone, y_stone) != 0) // Stone founds another stone, floor or exit door
        {
          y_stone = 0;

          pen(2);
          locate(1, 2);
          printw(++score); // Update score
        }
        else // Stone continue falling
        {
          pen(2);
          locate(x_stone, y_stone - 1);
          printc(' ');
          locate(x_stone, y_stone);
          printc(253);
        }
      }
      else // Create new stone
      {
        if (rand() % 5 == 0) // Calculate new column stone by random
        {
          x_stone = rand() % 38 + 1 + (x_exit == 1) * 2;
        }
        else // Calculate new column stone try filling the spaces where there is not stone
        {
           n1 = x_exit == 1 ? 3 : 1;
           n2 = x_exit == 1 ? 40 : 38;
           i = 24;
           c = 0;
           do
           {
             for (n = n1; n <= n2; ++n) if (*char_address(n, i) == 0 || i == y_man + 1 && (n == x_man || n == x_man + 1)) ++c;
             if (c == 0) --i;
           }
           while (c == 0); // Calculate in i the first row where there is a column witout stone

               // Calculate random number between 1 and number of columns without stone in row i and search the column of that position in row i without stone
               for (c = rand() % c + 1, x_stone = n1, n = 1; n <= c; ++n, ++x_stone)
                 while (!(*char_address(x_stone, i) == 0 || i == y_man + 1 && (x_stone == x_man || x_stone == x_man + 1))) ++x_stone;
               --x_stone;
        }

        y_stone = 3;
      }
    }

    if (alive)
    {
      for (s = 1000; s >= 500; s -= 100) sound(2, s, 5, 15, 0, 0, 0); // Sound for win
      if (--y_exit < 4) y_exit = 20; // Increment height of exit door
    }

    remain(music_block); // Finalize music
  }

  if (!lives)
  {
    pen(1);
    locate(12, 12);
    prints("G A M E   O V E R");
    locate(7, 14);
    prints("Press SPACE to continue ...");
    while (testkey(47) == -1);
  }
} // End main loop

TestManMoved: // Test if man is moved and update image in screen
if (x_man != x_man_prev || y_man != y_man_prev)
{
  put_image(x_man_prev, y_man_prev, background_man);
  get_image(x_man, y_man, background_man);
  put_image(x_man, y_man, step_man ? (x_man % 2 ? sprite_man_right_stop : sprite_man_right_move) : (x_man % 2 ? sprite_man_left_stop : sprite_man_left_move));

   x_man_prev = x_man;
   y_man_prev = y_man;
}

return;

PlayMusic: // Play music
array word notes = { 379, 338, 319, 338, 379, 379, 338, 319, 253, 338, 319, 379, 379, 338, 319, 338, 338, 379, 379, 338, 319,
                     253, 338, 319, 379, 269, 253, 253, 253, 253, 239, 253, 284, 338, 319, 284, 284, 284, 284, 253, 284, 319, 0 };
sound(1, **q, 20, 12, 0, 0, 0);
if (**(q += 2) == 0) q = notes;
return;

// *****************
   InitializeScreen:
// *****************
cls();
paper(1);
locate(1,25);
printc(18);
paper(0); // Floor

for (i = 1; i <= lives; ++i) put_image(2 * i + 29, 1, sprite_man_right_move); // Lives
pen(1);
locate(1, 1);
prints("Score");
pen(2);
locate(1, 2);
printw(score); // Score

pen(2);
locate(15, 1);
prints("Oh Mummy 2!");
locate(15, 2);
repeat (11) printc(#9A);
put_image(12, 1, sprite_mummy_right);
put_image(27, 1, sprite_mummy_left); // Title

x_exit = (rand() % 2 ? 39 : 1); // Calculate side of exit door
pen(1);
locate(x_exit, y_exit - 1);
prints("\xFE\xFF");
locate(x_exit, y_exit + 2);
prints("\xD0\xD0"); // Exit door

x_man = x_man_prev = 19;
y_man = y_man_prev = 23;
step_man = 1; // 0 for left, 1 for right
alive = 1;
get_image(x_man, y_man, background_man);
put_image(x_man, y_man, sprite_man_right_stop); // Man

// Create some initial stones
pen(2);
repeat (25)
{
  // Calculate new stone column
  do
     x_stone = rand() % 40 + 1;
  while (x_stone >= x_man - 1 && x_stone <= x_man + 3);

  for (y_stone = 24; *char_address(x_stone, y_stone) != 0; --y_stone); // Calculate stone row

  locate (x_stone, y_stone);
  printc(253);
}

y_stone = 0;

return;

// ***************
   InitializeGame:
// ***************
score = 0;
lives = 5;
y_exit = 20;
return;

// *************
   Presentation:
// *************
array byte presentation_move_block[13]; // Block for timer

cls();
put_image(1, 1, sprite_mummy_left);
put_image(39, 1, sprite_mummy_right);
pen(2);
locate(6, 2);
prints("\x9A\x9A\x9A O h   M u m m y   2 ! \x9A\x9A\x9A\r\n\n\n");
pen(1);
prints("     You are in an egyptian pyramid and\r\nthe ceiling is falling. You need avoid\r\n");
prints("the falling stones and jump to top them\r\nin order to arrive to exit door.");
locate(3, 15);
prints("O left   P right   Q jump   ESC exit");
pen(2);
locate(8, 25);
prints("Press RETURN to start ...");

// Define man animation
x_man = x_man_prev = 1;
y_man = y_man_prev = 19;
step_man = 1; // 0 for left, 1 for right
every(10, PresentationMove, presentation_move_block);
q = notes;
every(12, PlayMusic, music_block);

while (testkey(18) == -1);
remain(presentation_move_block);
remain(music_block);
return;

PresentationMove: // Man animation routine
gosub TestManMoved;
if (step_man)
  if (x_man < 39) ++x_man;
  else step_man = 0;
else
  if (x_man > 1) --x_man;
  else step_man = 1;
return;

// ***************
   Initialization:
// ***************
array byte inks = { 0, 26 ,10, 16 }, clock[4], symbol_table[24];
array byte symbol_stone = { 126, 215, 169, 203, 241, 143, 227, 126 },
           symbol_exit1 = { 117, 69, 98, 69, 117, 0, 255, 255 }, symbol_exit2 = { 92, 72, 72, 72, 72, 0, 255, 255 };

// Symbols
symbolafter(253, symbol_table);
symbol(253, symbol_stone);
symbol(254, symbol_exit1);
symbol(255, symbol_exit2);

// Screen
mode(1);
border(*inks, *inks);
for (i = 0, p = inks; i <= 3; ++i, ++p) ink(i, *p, *p);
paper(0);
cls();

srand(**time(clock)); // Initialize seed for random numbers

return;

Resim Kütüphanesi

Kod:
function word char_address(byte, byte)
{
  "ld hl,3",
  "add hl,sp",
  "ld a,(hl)",
  "inc hl",
  "inc hl",
  "ld h,(hl)",
  "ld l,a",
  "dec h",
  "dec l",
  "jp __scr_char_position"
}

function byte get_image(byte, byte, word)
{
  "ld hl,2",
  "add hl,sp",
  "ld e,(hl)",
  "inc hl",
  "ld d,(hl)",
  "inc hl",
  "inc hl",
  "ld a,(hl)",
  "inc hl",
  "inc hl",
  "ld h,(hl)",
  "ld l,a",
  "dec h",
  "dec l",
  "call __scr_char_position",
  "ld b,2",
  "__get_image_1:",
  "push bc",
  "push hl",
  "ld b,8",
  "__get_image_2:",
  "push bc",
  "push hl",
  "ld bc,4",
  "ldir",
  "pop hl",
  "ld bc,2048",
  "add hl,bc",
  "pop bc",
  "djnz __get_image_2",
  "pop hl",
  "ld bc,80",
  "add hl,bc",
  "pop bc",
  "djnz __get_image_1",
  "ret"
}

function byte put_image(byte, byte, word)
{
  "ld hl,2",
  "add hl,sp",
  "ld e,(hl)",
  "inc hl",
  "ld d,(hl)",
  "inc hl",
  "inc hl",
  "ld a,(hl)",
  "inc hl",
  "inc hl",
  "ld h,(hl)",
  "ld l,a",
  "dec h",
  "dec l",
  "call __scr_char_position",
  "ex de,hl",
  "ld b,2",
  "__put_image_1:",
  "push bc",
  "push de",
  "ld b,8",
  "__put_image_2:",
  "push bc",
  "push de",
  "ld bc,4",
  "ldir",
  "ex de,hl",
  "pop hl",
  "ld bc,2048",
  "add hl,bc",
  "ex de,hl",
  "pop bc",
  "djnz __put_image_2",
  "ex de,hl",
  "pop hl",
  "ld bc,80",
  "add hl,bc",
  "ex de,hl",
  "pop bc",
  "djnz __put_image_1",
  "ret"
}
« Son Düzenleme: Ocak 26, 2008, 17:10:45 ÖS Gönderen: Alcofribas » Logged

Sayfa: [1]   Yukarı git
Yazdır
Gitmek istediğiniz yer: