Значок ресурса

Animation

Нет прав на скачивание
Автор: Duncan Overton,Mike Rapps
Год: 1984
Издатели: ZX Computing
Производитель: Sinclair User
Языки: 🇬🇧 Английский
Формат: 📼 TZX лента
Требования: 🖥️ ZX Spectrum 48K

Ссылки:
Страница на ZXArt
Страница на World Of Spectrum
Страница на Spectrum Computing

Скриншоты:
Animation_3.gif
animatmr.png


animatmr.png
Animation





Get things moving with Duncan Overton's


graphics program.





It all began whilst watching some software company's logo


reveal itself, stripe by stripe, on the TV screen. Loading


a screen string from tape is a slow operation, quite magi-


cal and entertaining when first seen, but slow. It becomes


plain boring when you have to watch that logo every time


you want to give the Alien Menace a good sorting out.


Having loaded a screen string you wish to use, just one


misplaced finger and it's lost, needing retrieval from


tape (where is that Microdrive?). So why not invent a


routine to shunt screenfuls into memory and recall them


when needed?


This is easy enough to do using PEEK and POKE, PEEKing


bytes from address 16384 onwards and POKEing them into


higher memory. As there are 6912 screen bytes, the process


is even slower than loading from tape, and Machine Code


becomes necessary. For the novice who is only used to


BASIC, the structure of Code operations seems very obscure.


With a little persistence, however, Code seems to be like


any other area of programming, easier to learn once you


have a specific need to be met. Once the sequence of oper-


ations is properly visualised, trial and error will get you


there in the end. One point soon learnt is that you must


tape each program before you RUN it - in Code, crashes are


invariably fatal!


There are over 40,000 bytes available on the 48K for


programs and storage space, so up to 5 screenfuls could be


stored. Program 1 [found below] is a Code routine to move


6912 bytes from one starting adderss to another. In order


that this routine can be used and modified easily, it may


be entered from a DATA statement in BASIC. For this, it


needs to be written in decimal form. Bytes 2,3 and 5,6 are


the addresses, which are written in a manner illogical to


common mortals. Byte 3 is the number of 256s in the ad-


dress, and byte 2 is the remainder from this division. So


addess 33000 is 33000/256 which equals 128, remainder 232,


and is entered as 232, 128, which the little Z80 chip seems


to understand perfectly.


Program 2 [found on the accompanying TZX as "animcode"]


is a BASIC routine to enter and run the Code program using


specified addresses. The Code is placed at the top end of


memory, 64000 to 64020, and is preserved from NEW using


line 1000. Screen strings can be stored as low as 25000 in


memory provided only a small BASIC program is stored as


well. The storage addresses increase by 7000 for each new


entry. Enter and RUN the program, using addresses 16384 and


25000, and then set up a screen design. Enter RANDOMIZE USR


64000, and nothing at all will appear to happen. But with


the specified addresses, the screen is now copied into


memory from 25000 to 31912 (PEEK it and see). Clear the


screen and RUN the BASIC program again, entering address


25000 first and 16384 second. RANDOMIZE USR 64000 again and


your screenful will return, considerably more quickly than


using PEEK and POKE. Four further screenfuls can be stored


and retrieved in the same way.


So what has all this to do with animation? Well, if the


code routine is used to recall screenfuls repeatedly in


cycle, then interesting possibilities arise. Program 3 [on


the TZX as "Starspin"] uses the Code routine, at line 100,


to store 4 designs. These 4 designs are created in line 7


to 70, and are each slightly different. Lines 200 onwards


recall these blocks in cycle continuously, and Hey Presto!


you have an animated Spectrum.


[ Note the red streaks, which are a result of drawing the


new screen over the old screen's attributes. This could be


avoided with a careful set-up of the attributes of each


screen, but that would go a bit far for a demonstration


like this. Note also that a clever machine code programmer


knows about the LDIR instruction, as demonstrated in


"StarLDIR" - which is both rather shorter and slightly


faster than the article's original! ]


For those of us used only to BASIC programming it is


awe-inspiring to calculate that, as one revolution of the


figures takes about 7 seconds, and involves 64 'frames',


then some 63000 bytes are being shunted around each


second!


Spinning wheels, wriggly caterpillars, travelling waves


and rotating solids can all be produced in the same way.








Program 1





HEX MNEMONICS FOR HUMANS


11,XX,XX LD DE,address 1 Set 'read from' address


21,XX,XX LD HL,address 2 Set 'load to' address


06,1B LD B,27 Set up a loop of


C5 PUSH BC 6912 repetitions


06,00 LD B,256


1A LD A,(DE) Put contents of add. 1


77 LD (HL),A into add. 2


13 INC DE Move add. 1 & add. 2


23 INC HL on to next address


10,F9 DJNZ,-6 Other end of


C1 POP BC loop


10,F4 DJNZ,-11


C9 RET Return to BASIC








[ Program 1a - LDIR version





HEX MNEMONICS FOR HUMANS


01,00,1B LD BC,6912 Set number of bytes to move


21,XX,XX LD HL,address 1 Set 'read from' address


11,XX,XX LD DE,address 2 Set 'load to' address


ED,B0 LDIR Move BC bytes from HL to DE


C9 RET Return to BASIC ]
Автор
Verter_bot
Загрузки
0
Просмотры
1
Расширение
zip
Размер
1.1 КБ
Хэш
56763fe4a087ba46af2b1356aded1f87
Первый выпуск
Последнее обновление

Оценки

0.00 звезд(ы) 0 оценок
Назад
Вверх