PROGRAMMING DYNAMIC PROGRAMS --------------------------------------------------- (C) Mythos Without making a long introduction and description of the procedure I wanted 6s say that the term "dynamic program" is not most likely some standard reference definition, a taken by me due to my inability to name this type of program somehow different. Such programs and procedures exist and are used in demos. The point of such programs is to create, change and destroy themselves in real time, resulting in amazing savings address and disk space. In demos this is a creation procedures nepe6pocku sprites and screens, tables (which, I think ,can also be attributed to one of the aspects of this type programming). In principle, this is also used in games. Procedures, code creators, or tables do not need more speed, and memory savings are noticeable, which I think should entailentails more intensive study of this issue and widespread introduction of dynamic programming technologies into programs created today. What I hope is being done now on the Spectrum stage. And now a little about makers (mactepax, as you wish). I I'll try to classify them. 1. disposable 2.reusable It is impossible to attribute any to one or the other certain procedures, the only difference is that after execution of the first type of procedure, the latter must be destroyed, either itself, or the calling program does it. A after performing a procedure of type two, the last one remains in memory for future use. It is difficult to give any recommendations in writing certain procedures, it is absolutely clear that the maker must be significantly smaller in volume than the procedure being created, and its own pa6oty naturally finish faster than your heart can manage take the next shot :)Below is the procedure for creating scrollers in real time mode, the maker is reusable, but it can be easily converted into whatever you want. How you can use it: Let's say you're writing a text or music editor, and so on. Naturally, since you are writing a cool editor, you need a fast one scroller, a fast one, as you know, quickly eats up your memory, a for the editor you need at least two types of scroller (up/down) yes This and files are shown beautifully and with a screen scroller, and here it is already the size of the output window is different :( you need other scrollers (don’t forget that fast ;-) ) so the maker creates in the memory you specify the type of scroller you specified with the ones you specified again parameters. And it does this in less than 1.5 interrupts. If, for example, you are not using a scroller at the moment, then it is quite possible to use a memory area for which intended to be used for other needs. Don't forget to reset after overwriting it, the Status variable, if you have one of course you are using. A few variables: Status is introduced to be able to recognize what typeThe scroller was last created. al,alil,as are described along with the code text. They set the number of lines (pixel/string) for shift Be careful when specifying the starting shift addresses, as your program uses scrolling, they must be carefully calculated and specified. The procedure only shifts by eight pixels in any direction and only by the number of characters in width multiples of 8. If necessary, I can modify it to work with the width multiple of 2. After some minor modifications (when he figures it out) he can shift by fewer or more pixels only by verticals. A small example of parameters: It is necessary to shift upward the area (l,h) 16x11 (in familiar places) initial coordinates of the window (in x,y pixels) (16,17) line widthshift i=6 i.e. from each standard string 6 pixels are taken for shifting. Don't try to make a shift here with such parameters that start coordinate "y" + line_width was 6 times greater than The next number after "y" is kapthoe 8 in ascending order. It will be terrible looks and boo6re can hang. Next, the parameters are set, Let's translate the window coordinates into the screen address, let's call it adr1 there will be a so-called “to” address i.e. where is the shift? Address adr2 (address "from") in this link is considered as the address "to" shifted down to the familiar place. In variables al=h, alil=i, as=2 (as) the number of segments in line. segment=8 familiar places in our case - this gives the width windows = 16 characters. Before calling the makeslu procedure, look at the transformations with addresses before sending them to registers. Maker will do his job and feel free to start the scrolling procedure. The name you must enter in in your program: "scroll" Upload, study, write if you find any glitches in it. Although I checked, but you never know, you can’t keep an eye on everything. PROCEDURE:MAMESCRL;ПЕРЕМЕННАЯ STATUS ;ОПРЕДЕЛЯЕТ ТИП МОДА СДВИГА ;Q-НЕОПРЕДЕЛЕН ;1-LEFT ;2-RIGHT ;3-DOWU ;4-UP ;ПЕРЕМЕННАЯ STPM ;ЗНАМ EE ОПРЕДЕЛЯЕТ НАПРАВЛЕНИЕ ;ВЫБОРMИ 8-МИ БАЙТНЫХ СЕГМЕНТОВ ;(+) ВПРАВО ;(-) LEFT ;VALUE - STEP, FIXED = 8 ; ;LEXICON OF PROCEDURES: ;FROM-REFERS TO M ADDRESS IN THE EMERGENCY AREA ; ADDRESS OF THE FIRST BYTE IN ITS MOT. ; WILL MOVE ;THE - -//- ,ADDRESS OF THE FIRST BYTE IN IT ; MUDA MOVE BYTE AND3 (FROM) ; ;3AMEAAHUE ABOUT ANGLES SPEAKS ABOUT OMHE SHIFT ;T.E. WHERE SHOULD THE ADDRESS BE LOCATED (TO,FROM);IN MAMOM CORNER OF SHIFT ; ; FOR THE PROCEDURE TO WORK, IT IS NECESSARY TO SET ;SCROLL VARIABLE THIS WILL BE THE ADDRESS IN MOTO- ;THE SHIFT PROCEDURE WILL BE CREATED ; MAMESLR ;MAME SCROLL RIGHT ;SET: ;HL=FROM-7 ;DE=TO+1 ;UPPER RIGHT CORNER PUSH ВС LD ВС,Q-8 LD A,2;RIGHT JR MAMESCR-12 MAMESLD ;MAME SCROLL DOWU ;HL=FROM ;DE=ТО+8 ;НИЖНИЙ ЛЕВЫЙ УГОЛ PUSH ВС LD ВС,8 LD (STPM+1),ВС LD ВС,#2515;DEC Н;DEC D LD A,3;DOWU LD (STATUS+1),A LD A,#D6;SUB И JR MAMESCR MAMESLL ;MAME SCROLL LEFT ;HL=FROM ;DE=ТО+8 ;ВЕРХНИЙ ЛЕВЫЙ УГОЛ LD A,1;LEFT JR MAMESCR-12 MAMESLU ;MAME SCROLL UP ;HL=FROM ;DE=ТО+8 ;ВЕРХНИЙ ЛЕВЫЙ УГОЛ LD A,4;UP PUSH ВС LD ВС,8 LD (STPM+1),ВС LD ВС,#2414;IUC Н;IUC D LD (STATUS+1),A LD A,#С6;ADD A,И MAMESCR ;СОЗДАЕТ ПРОЦЕДУРУ СMРОЛИНГА ;A-CODE(ADD A,И/SUB И) ;ВС-CODE (IUC Н,IUC D/DEC Н,DEC D) ;AL - AMOUUT LIUES(STRIUG) FOR MOVIUG ;ALIL-AMOUUT LIUS(PIX)IU LIUE(STRIUG) MOVE ;AS-AMOUUT SEGMEUTS IU LIUE.SEG=8 ЗНАКОМЕСТ LD (ZMЗ),A LD (ZMЧ),A LD (ZMS),A LD(ZMб),A LD A,В LD (ZM1),A LD A,С LD (ZM2),A EXX PUSH ВС PUSH HL PUSH DE LD DE,SCROLL LD HL,STMAЗ LD ВС,4 LDIR;СОЗДАНИЕ КОДА LD SP,(Q) ;АДРЕС С MОTОРОГО ЗАПИСЫВАЕТСЯ КОД EXX AL LD В,8 ;MОЛИЧEСTВО CTPOM СДВИГАТЬ PUSH ВС PUSH DE PUSH HL ALIL LD В,8 ;MОЛИЧEСTВО ПИКСЕЛЬНЫХ ЛИНИЙ ;В CTPOME ИЗ 8-МИ ТАКИХ В СТРОКЕ ;ЗНАКОМЕСТ ,СДВИГАТЬ ;МАКС.=8,МИН=1 PUSH ВС PUSH DE PUSH HL AS LD A,4 ;MОЛИЧEСTВО СЕГМЕНТОВ ПО ВОСЕМЬ ;3HAMOMECT В CTPOME ,СДВИГАТЬ LD (STMA1+1),HL LD (STMA2+1),DE EXX LD ВС,14 LD HL,STMA1 LDIR ;СОЗДАТЬ МОД EXX STPM LD ВС,Q ;3HAM РЕГ.ВС:(+) ВПРАВО,(-) ВЛЕВО ПО ;CTPOME ADD HL,ВС ЕХ DE,HL ADD HL,ВС ЕХ DE,HL DEC A JPUZ,AS+2 РОР HL РОР DE ZM1 IUC Н ZM2 IUC D РОР ВС DJUZ ALIL+2 РОР HL РОР DE ;сдвиги адресов на знакомест в заданном направлении LD A,L ZMЗ ADD A,32 LD L,A JR ИС,$+6 LD A,Н ZMЧ ADD A,8 LD Н,A DEC DE LD A,E ZMS ADD A,32 LD E,A JR ИС,$+6 LD A,D ZMб ADD A,8 LD D,A IUC DE РОР ВС DJUZ AL+2 EXX IUC DE ;MEMBER ADRES WHERE STACM IS LD (SCROLL+2),DE DEC DE LD HL,STATUS LD ВС,4 LDIR ;СОЗДАТЬ МОД LD SP,Q РОР DE РОР HL РОР ВС EXX РОР ВС RET STMA1;ШАБЛОН LD SP,Q РОР HL РОР DE РОРВС РОР AF STMA2 LD SP,Q PUSH AF PUSH ВС PUSH DE PUSH HL STMAЗ LD (Q),SP;ШАБЛОН 2 STATUS LD SP,Q;ШАБЛОН 3 RET P.S. if you think a little you can transform this procedure so that it creates an attribute scroller. Scrollers will pa6otatb faster if this is all use alternate registers. Then sample at a time will increase to 16 bytes. ----------------------------------------------------------------
Share your thoughts about the article