From 0555bd8c9a100e55323eec4adaeb1e54f8ca39b7 Mon Sep 17 00:00:00 2001 From: Yogev Ezra Date: Sun, 30 Jan 2011 12:47:07 +0000 Subject: [PATCH] 'Donkey' game - merge with 0.8 sources from diamond's last nightbuild. git-svn-id: svn://kolibrios.org@1811 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/games/donkey/c_code.c | 9 +- programs/games/donkey/readme.txt | 6 +- programs/games/donkey/utils/donkey.bas | 132 +++++++++++++++++++++++++ programs/games/donkey/utils/file2c.cpp | 38 +++++++ programs/games/donkey/utils/gblib.txt | 34 +++++++ 5 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 programs/games/donkey/utils/donkey.bas create mode 100644 programs/games/donkey/utils/file2c.cpp create mode 100644 programs/games/donkey/utils/gblib.txt diff --git a/programs/games/donkey/c_code.c b/programs/games/donkey/c_code.c index 87114a071..921271d90 100644 --- a/programs/games/donkey/c_code.c +++ b/programs/games/donkey/c_code.c @@ -11,7 +11,7 @@ #include "donkey_02.h" #include "az.h" -char STR_DONKEY[] = {"D O N K E Y 0.7"}; +char STR_DONKEY[] = {"D O N K E Y 0.8"}; int start, paintbg, pause; int dox, doy; @@ -21,6 +21,9 @@ int drn, don; int speed; +char snd_ok[]={0x08, 0x89, 0x0f, 0}; +char snd_game_over[]={0x08, 0xa9, 0x0f, 0x09, 0x99, 0x0f, 0x11, 0x59, 0x0f, 0}; + GB_BMP screen, font, car01, car02, donkey01, donkey02, az; @@ -193,6 +196,7 @@ if (doy < -50) if ((drx == dox)&&(dry > doy-15)&&(dry < doy+15)) { + kol_sound_speaker(snd_game_over); don++; dry = 0; drn /= 10; @@ -324,6 +328,9 @@ for (;;) { if (-1 == pause) break; + + kol_sound_speaker(snd_ok); + drx *= -1; screen_draw(); } diff --git a/programs/games/donkey/readme.txt b/programs/games/donkey/readme.txt index 566ec27e5..a5aff388c 100644 --- a/programs/games/donkey/readme.txt +++ b/programs/games/donkey/readme.txt @@ -1,5 +1,5 @@ Игра Donkey -версия 0.7 +версия 0.8 ============== Интересна тем, что версию под DOS написал Билл Гейтс. @@ -8,9 +8,9 @@ Эта версия - ремейк для KolibriOS, потому что из оригинала заимствованы только интерфейс и правила, а код собственный. -Версия 0.7 написана с использованием библиотеки gblib. +Версия 0.8 написана с использованием библиотеки gblib. ============== автор: Александр Богомаз aka Albom (albom85@yandex.ru) -26 марта 2008 +23 июля 2008 diff --git a/programs/games/donkey/utils/donkey.bas b/programs/games/donkey/utils/donkey.bas new file mode 100644 index 000000000..057439c8d --- /dev/null +++ b/programs/games/donkey/utils/donkey.bas @@ -0,0 +1,132 @@ +REM The IBM Personal Computer Donkey +REM Version 1.10 (C)Copyright IBM Corp 1981, 1982 +REM Licensed Material - Program Property of IBM +DEF SEG : POKE 106, 0 +SAMPLES$ = "NO" +DIM CAR%(900) +GOTO 1010 +SAMPLES$ = "YES" +1010 KEY OFF: SCREEN 0, 1: COLOR 15, 0, 0: WIDTH 40: CLS : LOCATE 5, 19: PRINT "IBM" +LOCATE 7, 12, 0: PRINT "Personal Computer" +COLOR 10, 0: LOCATE 10, 9, 0: PRINT CHR$(213) + STRING$(21, 205) + CHR$(184) +LOCATE 11, 9, 0: PRINT CHR$(179) + " DONKEY " + CHR$(179) +LOCATE 12, 9, 0: PRINT CHR$(179) + STRING$(21, 32) + CHR$(179) +LOCATE 13, 9, 0: PRINT CHR$(179) + " Version 1.10 " + CHR$(179) +LOCATE 14, 9, 0: PRINT CHR$(212) + STRING$(21, 205) + CHR$(190) +COLOR 15, 0: LOCATE 17, 4, 0: PRINT "(C) Copyright IBM Corp 1981, 1982" +COLOR 14, 0: LOCATE 23, 7, 0: PRINT "Press space bar to continue" +1100 IF INKEY$ <> "" THEN GOTO 1100 +1110 CMD$ = INKEY$ +IF CMD$ = "" THEN GOTO 1110 +IF CMD$ = CHR$(27) THEN GOTO 1298 +IF CMD$ = " " THEN GOTO 1160 +GOTO 1110 +1160 DEF SEG = 0 +IF (PEEK(&H410) AND &H30) <> &H30 THEN DEF SEG : GOTO 1291 +WIDTH 80: CLS : LOCATE 3, 1 +PRINT "HOLD IT!" +PRINT "YOU'RE NOT USING THE COLOR/GRAPHICS MONITOR ADAPTER!" +PRINT "THIS PROGRAM USES GRAPHICS AND REQUIRES THAT ADAPTER." +PRINT "PRESS THE SPACE BAR TO CONTINUE." +DEF SEG +1240 IF INKEY$ <> "" THEN GOTO 1240 +1250 CMD$ = INKEY$ +IF CMD$ = "" THEN GOTO 1250 +IF CMD$ = CHR$(27) THEN GOTO 1298 +IF CMD$ = " " THEN GOTO 1298 +GOTO 1250 +1291 KEY OFF +ON ERROR GOTO 1295 +PLAY "p16" +GOTO 1300 +1295 COLOR 31, 0, 0 +PRINT "THIS PROGRAM REQUIRES ADVANCED BASIC -- USE COMMAND 'BASICA'": COLOR 15, 0, 0: FOR I = 1 TO 9000: NEXT: RESUME 1298 +1298 ON ERROR GOTO 0 +SCREEN 0, 1: COLOR 7, 0, 0: CLS : END +1300 REM +COLOR 0 +DEFINT A-Y +SCREEN 1, 0: COLOR 8, 1 +DIM Q%(500) +DIM D1%(150), D2%(150), C1%(200), C2%(200) +DIM DNK%(300) +GOSUB 1940 +GOSUB 1780 +CLS +DIM B%(300) +FOR I = 2 TO 300: B%(I) = -16384 + 192: NEXT +B%(0) = 2: B%(1) = 193 +1540 REM +CX = 110: CLS +LINE (0, 0)-(305, 199), , B +LINE (6, 6)-(97, 195), 1, BF +LINE (183, 6)-(305, 195), 1, BF +LOCATE 3, 5: PRINT "Donkey" +LOCATE 3, 29: PRINT "Driver" +LOCATE 19, 25: PRINT "Press Space "; +LOCATE 20, 25: PRINT "Bar to switch"; +LOCATE 21, 25: PRINT "lanes "; +LOCATE 23, 25: PRINT "Press ESC "; +LOCATE 24, 25: PRINT "to exit "; +FOR Y = 4 TO 199 STEP 20: LINE (140, Y)-(140, Y + 10): NEXT +CY = 105: CX = 105 +LINE (100, 0)-(100, 199): LINE (180, 0)-(180, 199) +1670 LOCATE 5, 6: PRINT SD: LOCATE 5, 31: PRINT SM +CY = CY - 4: IF CY < 60 THEN 2230 +PUT (CX, CY), CAR%, PRESET +DX = 105 + 42 * INT(RND * 2) +FOR Y = (RND * -4) * 8 TO 124 STEP 6 +SOUND 20000, 1 +A$ = INKEY$: IF A$ = CHR$(27) THEN 1298 ELSE POKE 106, 0: IF LEN(A$) > 0 THEN LINE (CX, CY)-(CX + 28, CY + 44), 0, BF: CX = 252 - CX: PUT (CX, CY), CAR%, PRESET: SOUND 200, 1 +IF Y >= 3 THEN PUT (DX, Y), DNK%, PSET +IF CX = DX AND Y + 25 >= CY THEN 2060 +IF Y AND 3 THEN PUT (140, 6), B% +NEXT: LINE (DX, 124)-(DX + 32, 149), 0, BF: GOTO 1670 +1780 CLS +DRAW "S8C3" +DRAW "BM12,1r3m+1,3d2R1ND2u1r2d4l2u1l1" +DRAW "d7R1nd2u2r3d6l3u2l1d3m-1,1l3" +DRAW "m-1,-1u3l1d2l3u6r3d2nd2r1u7l1d1l2" +DRAW "u4r2d1nd2R1U2" +DRAW "M+1,-3" +DRAW "BD10D2R3U2M-1,-1L1M-1,1" +DRAW "BD3D1R1U1L1BR2R1D1L1U1" +DRAW "BD2BL2D1R1U1L1BR2R1D1L1U1" +DRAW "BD2BL2D1R1U1L1BR2R1D1L1U1" +LINE (0, 0)-(40, 60), , B +PAINT (1, 1) +REM DIM CAR%(900) +GET (1, 1)-(29, 45), CAR% +RETURN +1940 CLS +DRAW "S08" +DRAW "BM14,18" +DRAW "M+2,-4R8M+1,-1U1M+1,+1M+2,-1" +DRAW "M-1,1M+1,3M-1,1M-1,-2M-1,2" +DRAW "D3L1U3M-1,1D2L1U2L3D2L1U2M-1,-1" +DRAW "D3L1U5M-2,3U1" +PAINT (21, 14), 3 +PRESET (37, 10): PRESET (40, 10) +PRESET (37, 11): PRESET (40, 11) +GET (13, 0)-(45, 25), DNK% +RETURN +2060 SD = SD + 1: LOCATE 14, 6: PRINT "BOOM!" +GET (DX, Y)-(DX + 16, Y + 25), D1% +D1X = DX: D1Y = Y: D2X = DX + 17 +GET (DX + 17, Y)-(DX + 31, Y + 25), D2% +GET (CX, CY)-(CX + 14, CY + 44), C1% +GET (CX + 15, CY)-(CX + 28, CY + 44), C2% +C1X = CX: C1Y = CY: C2X = CX + 15 +FOR P = 6 TO 0 STEP -1: Z = 1 / (2 ^ P): Z1 = 1 - Z +PUT (C1X, C1Y), C1%: PUT (C2X, C1Y), C2% +PUT (D1X, D1Y), D1%: PUT (D2X, D1Y), D2% +C1X = CX * Z1: D1Y = Y * Z1: C2X = C2X + (291 - C2X) * Z +D1X = DX * Z1: C1Y = C1Y + (155 - C1Y) * Z: D2X = D2X + (294 - D2X) * Z +PUT (C1X, C1Y), C1%: PUT (C2X, C1Y), C2% +PUT (D1X, D1Y), D1%: PUT (D2X, D1Y), D2% +SOUND 37 + RND * 200, 4: NEXT +FOR Y = 1 TO 2000: NEXT +CLS : GOTO 1540 +2230 SM = SM + 1: LOCATE 7, 25: PRINT "Donkey loses!" +FOR Y = 1 TO 1000: NEXT +CLS : GOTO 1540 \ No newline at end of file diff --git a/programs/games/donkey/utils/file2c.cpp b/programs/games/donkey/utils/file2c.cpp new file mode 100644 index 000000000..9f7492a6d --- /dev/null +++ b/programs/games/donkey/utils/file2c.cpp @@ -0,0 +1,38 @@ + +#include + +const char hextable[] = "0123456789abcdef"; + +int main(int argc, char *argv[]) +{ + +FILE *fin; +FILE *fout; +unsigned i; +int num; + +if (argc != 3) + { + printf ("file2c v0.2 by O.Bogomaz (albom85@yandex.ru)\nfile2c.exe file.in file.out\n\n"); + return -1; + } + +fin = fopen (argv[1], "rb"); +fout = fopen (argv[2], "wt"); + +fprintf(fout, "char array[]= {"); + +for (i = 0;; i++) + { + if ( 0 == i%16) + fprintf(fout, "\n"); + num = getc(fin); + if (feof(fin)) + break; + fprintf (fout, "0x%c%c,", (int)hextable[(num >> 4)], (int)hextable[(num & 0x0f)]); + } + +fprintf(fout, "\n };\n"); + +return 0; +} diff --git a/programs/games/donkey/utils/gblib.txt b/programs/games/donkey/utils/gblib.txt new file mode 100644 index 000000000..208ea44d1 --- /dev/null +++ b/programs/games/donkey/utils/gblib.txt @@ -0,0 +1,34 @@ + + Graphics Board Library + version 0.3 + + 26 июня 2008 г. + + ====================== + + Графическая библиотека. + Подобна к SDL, только сильно + упрощена. + + Пока поддердивается работа + только с режимом 24BPP. + + ====================== + + Реализованные функции: + + gb_pixel_set - поставить точку + gb_pixel_get - получить точку + gb_line - линия + gb_rect - прямоугольник + gb_bar - закрашенный прямоугольник + gb_circle - окружность + gb_image_set - изображение + gb_image_set_t - изображение с прозрачным + цветом + + ====================== + + автор : А. Богомаз aka Albom + e-mail: albom85@yandex.ru + сайт : http://albom06.boom.ru