Важная информация

User Tag List

Страница 4 из 4 ПерваяПервая 1234
Показано с 31 по 32 из 32

Тема: Генерация случайных чисел в заданном диапазоне

  1. #31
    Guru Аватар для Shiny
    Регистрация
    19.01.2017
    Адрес
    г. Арзамас
    Сообщений
    2,121
    Записей в дневнике
    36
    Спасибо Благодарностей отдано 
    0
    Спасибо Благодарностей получено 
    21
    Поблагодарили
    10 сообщений
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    кстати, о птичках. Непонятно, почему JP M,RANDOM3 ?

    Код:
    PROGRAM PITSTOP
    from Your Sinclair #20 (August 1987)
    
    If you want to know more about programming, take a Pitstop right here in
    our new program section! Each month it'll be bursting with routines from
    the top programmers, and seething with all your games and utility
    programs.
    
    
    Yes, it's all true! In this rinky premiere edition of Program Pitstop,
    we've got Jon Ritman of Batman and Head Over Heels fame, Dominic
    Robinson who wrote Zynaps and Uridium and Tim Follin, musician extra-
    ordinaire, who did the music for Agent X and Sentinel. All of them are
    here this month sharing their darkest programming secrets, for you to
    use free in your own programs! If that isn't enough for you, we've also
    got wacky David McCandless and his super Gauntlet Mapper program, plus
    an original and useful graphic utility from Khalid Jamil, called Peeker.
    
    Pitstop is going to be the indispensable programmers guide, featuring
    the best Spectrum programmers plus yourselves in the biggest pooling of
    programming talent since the Spectrum was invented. What we need are
    contributions from you. Is there a routine that does something fab that
    you used in your last game? Provided it's quite short, you're in with a
    chance to be featured in Program Pitstop. If you're a professional
    programmer, then please write in with a mugshot and some details. If
    you're just a talented amateur, then let the rest of the world see how
    brill you can be - who knows, you could find yourself up there with the
    big boys in no time!
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    PEEKER
    by Khalid Jamil (?)
    from Your Sinclair 20 (Aug.1987) - "Program Pitstop"
    [files PEEKER.*]
    
    
    [This was later claimed to have been lifted from a Spanish magazine ]
    [ - Microhobby #78 - and to have been written by Francisco Alexandre]
    [ - see letter below.                                           JimG]
    
    
    Now then, have you ever seen graphics in a game that you really liked
    and thought, "Hmm, with a little bit of tickling that would be just
    right for my new game!" Well, now you can! Khalid Jamil has come up with
    a very tidy solution, in the form of Peeker, an amazingly short program
    which allows you to look at a game's graphics or sprites to see how
    they're made up.
    
    
    Method
    
    Load Peeker with LOAD "". You'll be presented with a menu screen
    containing the graphics window, a small bar containing the start and end
    addresses of the program you're looking at, a short box containing the
    memory location presently being examined, and a menu box. The menu box
    contains the words PEEK, COLOR, POINT, LOAD, and SAVE. To access each of
    these options, press '6', then use 'Q' and 'A' to highlight the option,
    then finally press '0' (zero) to select it. To escape from an option
    press '6' again.
    
    
    Basic Program
    
    Here's the main program. Type it in and save it to tape as SAVE "PEEKER"
    LINE 1. It'll load up the code blocks and auto-run.
    
    PEEK - After loading the game, this option allows you to actually look
    at the graphics in memory. Scan forwards and backwards through memory
    with 'Q' and 'A'. If it looks crunched or just plain garbage, you can
    expand the data sideways to make it more readable with 'O' and 'P'. If
    the data seems to be off to one side, like the head of the character is
    on one side and the body on the other, you can scroll the data around
    with keys '5' and '8'.
    
    COLOR - Inverses the colour of the display window.
    
    POINT - This function points to the location in memory where the program
    is stored and how much there is of it. [Toggle between the high and low
    locations with 'O' and 'P'; return to the menu with 'A'. JimG]
    
    LOAD - Allows you to load in the main machine code block of the game you
    wish to inspect. If the game is too large to be resident in memory at
    the same time as Peeker; it won't crash, but will just stop loading.
    
    SAVE - Enables you to save the graphics data.
    
    
    Hex Loader
    
    [I didn't use the hex loader printed in the mag, so I've not]
    [included the comments about it here.                   JimG]
    
    
    Hex Dump 1
    
    This is the first bit of code, start address = 23296, and the length =
    143. Save as SAVE "PEEK CODE1" CODE 23296,143 after the Basic program on
    your tape.
    
    
    Hex Dump 2
    
    This is the second bit of code [UDGs, actually. JimG], start address =
    27936, and the length = 65. Save as SAVE "PEEK CODE2" CODE 27936,65
    after the first code block.
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    [letter from Your Sinclair 23 (Nov.1987)]
    
    VIVA L'ESPANA
    
    It's my duty with Francisco Alexandre to tell you the truth. The Peeker,
    a graphic utility that was published in the last issue of your mag, was
    first published in a Spanish magazine - Microhobby, no. 78 - and is by
    Francisco Alexandre. Khalid Jamil is telling porkies. Enclosed are three
    photocopies of the original listings of the program which was, and still
    is, "El Espia".
    
    Sorry about my English, but I think it's better than your Portuguese.
    
    Paulo J Lucas Martins
    Viseu, Portugal
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    GAUNTLET MAPPER
    by David McCandless
    from Your Sinclair 20 (Aug.1987) - "Program Pitstop"
    [files GAUNTMAP.*]
    
    
    Megawow! If you're a Gauntlet fan, then this is the utility for you.
    Having slaved along through Gauntlet and it's Deeper Dungeons, it's real
    nice to be able to get a map of the dam thing. Half the time spent
    playing the game seems to be flogging down dead end passages, only to
    turn around and see a Death on your tail! But don't get in a tizzy, 'cos
    help is on hand! David McCandless has come up with this wacky little
    program which actually maps each level for you and prints it out on a
    printer!
    
    Included in the program is a headerless save program, residing at
    address 31011. To use this simply RANDOMIZE USR 31011 and it'll save the
    Mapper code as a headerless file. There's no "Start Tape And Press Any
    Key" message, so the tape has to be running before you press ENTER. (For
    the technically minded, its a natty little routine you might want to use
    in your own programs. It goes like this: DD 21 B0 77 11 [74 01] 3E FF CD
    C2 04 C9, where the [bracketed] figures are the length, lo and hi bytes,
    in that order of course.)
    
    
    Method
    
    To use Mapper, simply connect your Spectrum to a printer, and load
    Mapper1 with LOAD "". Stop the tape and load side 1 of your Gauntlet
    tape as normal. Once loaded the screen will go blank. Stop the Gauntlet
    tape and insert your Mapper tape again. Press play and the headerless
    file will load in. Now the game will continue as normal, but you'll
    notice some of the character set has been corrupted. Don't worry, this
    is normal 'cos the Mapper code occupies this area. Now play the game as
    normal but Pressing 'T' will compress and print the current screen to
    your printer. Pressing 'R' will return you to the game, but if you
    haven't got enough time to play, pressing 'Y' will return you to the
    game, but with all the walls turned into exits for a quick getaway.
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    STAR TIP 1
    by Dominic Robinson
    from Your Sinclair #20 (Aug.1987) - "Program Pitstop"
    [files STARTIP1.*]
    
    Ever looked at the flashy rainbow
    coloured lettering on Hewson games and
    thought "Corky! I wish I could do that
    in my games!" Well now you can, because
    those awfully nice Hewson people have
    allowed Dominic Robinson, the
    exceedingly talented chap behind the
    Spectrum conversion of Uridium, to share
    it with you. His programming life at
    Hewson began when he worked on the team
    that built Pyracurse, and after Uridium
    and the game he's just completed,
    Zynaps, he looks, at the tender age of
    21, to be one of the top Spectrum
    programmers of 1987.
    
    The Rainbow Effects Processor is a very
    tidy group of routines, used in both
    Zynaps and Uridium to produce the
    amazing rainbow 3D effects on the title
    and hi-score screens. "In its simplest
    form, the Rainbow Processor can be used
    to increase the Spectrum's normal colour
    resolution, giving you a different
    colour on each pixel line, in a band
    twenty characters wide in the centre of
    the screen. With a little more work, the
    bars can be animated to produce some
    very un-Spectrum like effects. The
    Rainbow Processor runs in Interrupt Mode
    2, to keep it synchronised with the
    generation of the TV picture, so that
    different attribute values are fetched
    for each pixel line."
    
    Method
    
    To use the Rainbow Processor, you must
    set up a block of memory containing the
    colour for each pixel line of your
    display. This block can be 256 bytes
    long, although at most 192 will be used
    at one time, and it must not cross a
    page boundary. Starting at a block at an
    address which is a multiple of 256 will
    ensure that this condition is met. For
    example: 193*256-49408, which is
    conveniently placed just above the end
    of the code. Next POKE the address of
    your data into 49189 and 49190; call the
    routine at 49153 to initialise the
    interrupts, then POKE 49188 with the
    number of pixel lines you want
    displayed. This value should be a
    multiple of 8 for best results. Any
    value outside of the range 1 to 192 will
    switch off the rainbow effect until
    another value is used. The deeper the
    display you use, the less processor time
    will be available for Basic or any other
    code you have running. For this reason
    the rainbow effect can only really be
    used for title screens and special
    effects.
    
    Hex Dump
    
    Feed this, eight bytes at a time, into
    the Hex Loader from Peeker, and save it
    as SAVE "democode" CODE 49153,145.
    
    Demo Program
    
    This small Basic program demonstrates
    the facilities of the Rainbow Code. Save
    it as SAVE "RAINBOW" LINE 2000. When you
    run it, it will load and activate the
    machine code, upon which the screen will
    go black for a couple of minutes while
    the demo picture is drawn. So be
    patient; the result is stunning.
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    STAR TIP 2
    by Tim Follin
    from Your Sinclair #20 (Aug.1987) - "Program Pitstop"
    [files STARTIP2.*]
    
    This amazing three-channel sound routine
    is the product of the versatile musical
    talent of Tim Follin, the man behind the
    tunes on Mastertronic's Agent X, and
    Firebird's spectacular Sentinel. If you
    thought these were the corkiest sonics
    you've heard on any Speccy game, you'll
    be thrilled to atoms over this chunk of
    machine code music!
    
    Tim is currently working on a brilliant
    new routine for 6-channel sound with
    chorus bass, 128K snare drum, echo on /
    off / delay time, portamento, and full
    ADSR! This fabby routine is to appear on
    a brand new game called Red 5, by Peter
    Gough, so keep a look out for it in the
    near future.
    
    Method
    
    The code begins at 40000 and is a mere
    1340 bytes long. First CLEAR 39999, then
    LOAD "" CODE. To hear the tune, simply
    RANDOMIZE USR 40000. Any key breaks.
    
    Note: Tim has asked us to say that
    although he doesn't mind you using the
    tune in your own programs, he does
    retain copyright on it, so it can't be
    used for commercial games.
    
    Hex Dump
    
    Type the following hex dump into the hex
    loader and save as SAVE "TUNE" CODE
    40000,1340. Good luck!
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    STAR TIP 3 (Random Number Generator)
    by Jon Ritman
    from Your Sinclair #20 (Aug.1987)
    [files STARTIP3.*]
    
    If you liked Head Over Heels and Batman, then you'll know that Jon Ritman,
    along with his partner Bernie Drummond, knows a thing or two about program-
    ming brilliant games. One of the most important things in a good arcade
    adventure, or so it seems, is a random number generator.
    
    "This is the 32-bit random number generator routine I used in Batman and
    Head Over Heels. The routine is quite fast and returns a reasonable random
    number. This version returns with HL holding a 16-bit random number. However,
    if you need all 32 bits, simply add the instruction LD DE,(SEED+2) just
    before  the RET at the end. The 32-bit seed may be changed to any value of
    your choice."
    
    So here it is, for all of you assembly junkies, the listing, which can be
    located anywhere suitable in memory. For those of you that haven't got an
    assembler, there's also a hex dump of the code for you to load in via a
    suitable hex loader. For convenience we've assembled it to 30000 (7530 hex),
    and in case you're wondering, its length is 45 bytes. [It's actually 46
    bytes. JimG]
    
    
    SEED:       DB "Jon!"
                
    RANDOM:     LD HL,(SEED+2)
                LD D,L
                ADD HL,HL
                ADD HL,HL
                LD C,H
                LD HL,(SEED)
                LD B,H
                RL B
                LD E,H
                RL E
                RL D
                ADD HL,BC
                LD (SEED),HL
                LD HL,(SEED+2)
                ADC HL,DE
                RES 7,H
                LD (SEED+2),HL
                JP M,RANDOM3
                LD HL,SEED
    RANDOM2:    INC (HL)
                INC HL
                JR Z,RANDOM2
    RANDOM3:    LD HL,(SEED)
                RET
    
    30000:2ADD005529294C2A=548
    30008:DB0044CB105CCB13=820
    30016:CB120922DB002ADD=746
    30024:00ED5ACBBC22DD00=973
    30032:FA5A7521DB003423=796
    30040:28FC2ADB00C90000=754
    
    
    = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    
    
    --
    Another Fine Product transcribed by:
    Jim Grimwood, Weardale, England (http://www.users.globalnet.co.uk/~jimg/)
    --

  2. #31
    С любовью к вам, Yandex.Direct
    Размещение рекламы на форуме способствует его дальнейшему развитию

  3. #32
    Member Аватар для Vladson
    Регистрация
    14.01.2008
    Адрес
    Эстония, Таллинн
    Сообщений
    177
    Спасибо Благодарностей отдано 
    16
    Спасибо Благодарностей получено 
    24
    Поблагодарили
    14 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Тут есть пару примеров...
    http://zx-pk.ru/threads/9031-etyudy....862#post577862
    Разрабатываю новый сетевой протокол
    Variable Length Advanced Data Sending Over Network
    Что он будет делать и зачем нужен не знаю, разработал пока только название.

Страница 4 из 4 ПерваяПервая 1234

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Похожие темы

  1. Ответов: 54
    Последнее: 10.08.2020, 14:28
  2. генератор случайных чисел на БК
    от litwr в разделе БК-0010/0011
    Ответов: 6
    Последнее: 28.09.2018, 14:06
  3. Генерация синуса
    от Hacker VBI в разделе Программирование
    Ответов: 154
    Последнее: 02.06.2014, 15:54
  4. Генерация лабиринтов
    от TomCaT в разделе Программирование
    Ответов: 90
    Последнее: 26.06.2012, 10:59

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •