Adventurer #11
31 июля 2000 |
|
Exchange of experience - Game Making 2: The various methods for deriving sprites (based on the game Full Shit).
(C) DEMON / XPC / CPU GAME MAKING # 2 Hail, wandered here ... We are here again (see ADV # 10) on the shitty-din makinge>: -> Well, let's start with the sprite vyvodilok all plain and simple - they are: - With per-pixel coordinates of O and znakomestovymi; - With and without masochkoy masochki; - With and without attributes. Then there are combinations of these lazhi. Divided into types by the method organization output (depends on the structure storage infrastruc-tion in sprites) I will not, still does not list all, not even I remember how to store the sprites in the shitty sprite generator of THD (goats), which was my first program of its kind. A few words about vyvodilkah sprites: I believe they must meet certain conditions, for example, I did not need to stack-fast 'Marketing, and to oherennnyh size razdekranchennye because yuzalis both screens, then vyvodilka had to sit in the main Memory Speck (# 5b00-# bfff), and apart from her a lot of things were there. I'll tell you about the three vyvodilkah; on Y they pixel at X znakomestovye two of them and one pixel. 1. X - ZNAKOMESTOVAYA Unmasked Everything is standard, and without any fucking with a stack of bloat and other oddities, the simpler, the less # proximity. But if you have the desire to fuck interrupt and trace stack, flag of your hands ... So in 1932 LDI - it rulez, just 16 cycles per byte (and to my even-tact Scorpion, too). Set the coordinates in the DE, the size of sprite sprite BC himself in HL, we do CALL ssp, and he is on screen (if there are no correctly, the screen is likely to will be shit). Protsedurka this is nothing no checks and returns nothing as it is the lowest level of the nucleus bend. Do you want to - or even redone better to do his will be proud of ... WARNING! In the present listings profanity - the Directive XAS 'a. ; (C) DEMON / XPC ; Sprite x_Symbol Print without mask ; Average_Speed = 18.5 t / b (Scorp) ; Prog_Len = 120 b ;-------------; In: HL-sprite ; DE-coord (X-sim, Y-pix) ; BC-size (Y-pix, X-sym) ;------------- Ssp PUSH IX LD IX, wo_r_ok +4; forward and LD A, C; displace the loop ADD A, A; by LDI SUB 64; through JP (IX) NEG LD C, A LD A, B LD B, 0 ADD IX, BC LD B, A PUSH HL CALL adres_y; calculation of addresses EX DE, HL POP HL JR wo_r_ok; enter a loop ... wo_rinc 28 + LD A, E; 4 ADD A, 32, 8 (7) LD E, A; 4 JR C, wo_r_ok; 8 (7) / 12 LD A, D; 4 SUB 8 8 (7) LD D, A; 4 JP wo_r_ok; 10 wo_ylop INC D; 4 LD A, D; 4 AND 7, 8 (7) JR Z, wo_rinc; 8 (7) wo_r_ok PUSH DE; 10 LD C, D; Schaub was 4 C> 32 JP (IX); 8 ! ASSM 32, 32-th instruction LDI LDI; 16 ! CONT POP DE; 12 (11) DJNZ wo_ylop; 14 (13) POP IX RET ;------------- Calculation of addresses in the screen ; In: DE-X (sym), Y (pix) ; Out: HL-adres in screen ;------------ Adres_y LD L, D LD A, E AND 7 LD H, A LD A, E AND # 38 RLCA RLCA OR L LD L, A LD A, E AND # C0 RRA RRA RRA OR H LD H, A LD A, (how_scr) OR H LD H, A RET ;------------- VAR how_scr DB # 40 Contacts listed in critical areas the first figures are valid for the Scorpion, in brackets - for everything else. By the way, Scorpion on my tests show their 74,884 t in Interrupt chetno-t-vym and from 71,141 to 71440 on odd-t-vym teams. Partly how_scr is crucial in order to screen any currently running program (not visible, and working!), # 40 for 5 and # C0 for the 7 th, for example: draw a 5-second screen (how_scr = # 40), and see the 7 th, he suddenly interrupted: we define the variable pag_or (see below) that including a 7-th screen, change to how_scr # C0 and arrow to display a seventh, as All GFXprotsy, work through that variable, then and addresses of all will be calculated for the appropriate screen. You can blather that it is stupid and should be would simply be cut in the 5 th with # C000 (Sorry, Elf), but when working with two screens, I it came to this method. 2. X - ZNAKOMESTOVAYA WITH MASK ; (C) DEMON / XPC ; Sprite x_Symbol Printer with Mask ; Average_Speed = 50 t / b (Scorp) ; Len = 287 b ;------------; In: HL-sprite with mask ; DE-coord X (sym), Y (pix) ; BC-size Y (pix), X = (sym) ;------------ Ssp_m PUSH IX; truncated same LD IX, wm_r_ok +3 LD A, C ADD A, A ADD A, A ADD A, C ADD A, C ADD A, C SUB 224 NEG LD C, A LD A, B LD B, 0 ADD IX, BC LD B, A PUSH HL CALL adres_y LD D, B LD B, H LD C, L POP HL JR wm_r_ok; cycle again ... wm_rinc; 28 + LD A, C; 4 ADD A, 32, 8 (7) LD C, A; 4 JR C, wm_r_ok; 4 (7) / 12 LD A, B; 4 SUB 8 8 (7) LD B, A; 4 JP wm_r_ok; 10 wm_ylop INC B; 4 LD A, B; 4 AND 7, 8 (7) JR Z, wm_rinc; 8 (7) wm_r_ok LD E, C; 4 JP (IX); 8 ! ASSM 1932 LD A, (BC); 8 (7) to a byte screen AND (HL); 8 (7) impose a mask INC HL; 6 and byte sprite OR (HL); 8 (7) Assume the result INC HL; 6 LD (BC), A; 8 (7) put in a screen INC C; 4 ! CONT LD C, E 4 DEC D 4 JP NZ, wm_ylop; 14 POP IX RET Sprite dolzhon have the following structure: the byte-mask, byte-date baytmaska, etc., as does the Sprite Land of DR. About two percent of these acts the following rule:, "BETTER wider and shorter than the already Length ", ie the size of the sprite X = 32 and Y = 10 draws faster than the size of X = 10 Y = 32, although the size in bytes of the same. 3. Per-pixel WITH MASK Made this procedure is mainly Elf, XN0ByS something done too. When Kostya (Elf) said that this is supposedly faster, then I have to dispute it, darling, zafastil. Winning over the old in averaged 5000-7000 cycles, but if we take the sprite large sizes (subject ate about 45000 cycles), then it (winning) is proportional increases. And all through the use of undocumented commands; think you can still speed, but broke ... ; FAST PIXEL'S SPRITE WITH MASKA ... ; By ELF / AURYN 'XN0ByS/SG ; ... FASTEST ; By DEMON / XPC '99 ; IN: HL ADR_OF SPRITE ; D Coord X in pIXels ; E Coord Y in pIXels ; C-x_size symbol ; B-y_size pIXel spr_pxm PUSH HL CALL adres_p EX DE, HL ADD A, A PUSH BC LD C, A LD B, 0 LD HL, rol_tab ADD HL, BC LD A, (HL) INC HL LD H, (HL) LD L, A LD (pxspr +1), HL POP IY POP HL pxspr JP bit_0 ; In IY-Y 'X size ; HL-SPRITE WITH MASK ; DE-ADRES ON SCREEN bit_0 LD C, LY bit_0l1 LD B, C LD LX, E bit_0l2 LD A, (DE) AND (HL) INC HL OR (HL) LD (DE), A INC HL INC E DJNZ bit_0l2 LD E, LX CALL down_DE DEC HY JR NZ, bit_0l1 RET bit_1 EX DE, HL LD A, HY LD HX, A bit1_l1 LD HY, LY LD A, L EX AF, AF ' bit1_l2 LD BC, # ff LD A, (DE) SCF RRA RR C AND (HL) LD (HL), A INC DE LD A, (DE) RRA RR B OR (HL) LD (HL), A INC L INC DE LD A, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit1_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit1_l1 RET bit_2 EX DE, HL LD A, HY LD HX, A bit2_l1 LD HY, LY LD A, L EX AF, AF ' bit2_l2 LD BC, # ff LD A, (DE) SCF ! ASSM 2 RRA RR c ! CONT AND (HL) LD (HL), A INC DE LD A, (DE) ! ASSM 2 RRA RR B ! CONT OR (HL) LD (HL), A INC L INC DE LD a, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit2_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit2_l1 RET bit_3 EX DE, HL LD A, HY LD HX, A bit3_l1 LD HY, LY LD A, L EX AF, AF ' bit3_l2 LD BC, # ff LD A, (DE) SCF ! ASSM 3 RRA RR C ! CONT AND (HL) LD (HL), A INC DE LD A, (DE) ! ASSM 3 RRA RR B ! CONT OR (HL) LD (HL), A INC L INC DE LD A, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit3_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit3_l1 RET bit_4 EX DE, HL LD A, HY LD HX, A bit4_l1 LD HY, LY LD A, L EX AF, AF ' bit4_l2 LD BC, # ff LD A, (DE) SCF ! ASSM 4 RRA RR C ! CONT AND (HL) LD (HL), A INC DE LD A, (DE) ! ASSM 4 RRA RR B ! CONT OR (HL) LD (HL), A INC L INC DE LD A, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit4_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit4_l1 RET bit_5 EX DE, HL LD A, HY LD HX, A bit5_l1 LD HY, LY LD A, L EX AF, AF ' bit5_l2 LD A, (DE) LD C, A LD A, # ff ! ASSM 3 SLI C RLA ! CONT AND (HL) LD (HL), A INC DE LD A, (DE) LD B, A XOR A ! ASSM 3 RL B RLA ! CONT OR (HL) LD (HL), A INC L INC DE LD A, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit5_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit5_l1 RET bit_6 EX DE, HL LD A, HY LD HX, A bit6_l1 LD HY, LY LD A, L EX AF, AF ' bit6_l2 LD A, (DE) LD C, A LD A, # ff ! ASSM 2 SLI C RLA ! CONT AND (HL) LD (HL), A INC DE LD A, (DE) LD B, A XOR A ! ASSM 2 RL B RLA ! CONT OR (HL) LD (HL), A INC L INC DE LD A, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit6_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit6_l1 RET bit_7 EX DE, HL LD A, HY LD HX, A bit7_l1 LD HY, LY LD A, L EX AF, AF ' bit7_l2 LD A, (DE) LD C, A LD A, # ff SLI C RLA AND (HL) LD (HL), A INC DE LD A, (DE) LD B, A XOR A RL B RLA OR (HL) LD (HL), A INC L INC DE LD A, C AND (HL) OR B LD (HL), A DEC HY JR NZ, bit7_l2 EX AF, AF ' LD L, A CALL down_HL DEC HX JR NZ, bit7_l1 RET down_HL INC H LD A, H AND 7 RET NZ LD A, L ADD A, 32 LD L, A RET C LD a, H SUB 8 LD H, A RET down_DE INC D LD A, D AND 7 RET NZ LD A, E ADD A, 32 LD E, A RET C LD A, D SUB 8 LD D, A RET adres_p LD A, E AND A RRA SCF RRA AND A RRA XOR E AND # f8 XOR E LD H, A LD A, D RLCA RLCA RLCA XOR E AND # c7 XOR E RLCA RLCA LD L, A LD A, D AND # 07 RET rol_tab DW bit_0, bit_1, bit_2, bit_3 DW bit_4, bit_5, bit_6, bit_7 The meaning of the following: computed how many bytes have rollirovat sprite with a mask, the table is taken corresponding procedure, and the process cycle begins. Sprite has the same structure as described above. Perhaps in This procedure can be four-day clean up, if you wish, although it works without problems and for quite some time we yuzaetsya in this form. All these vyvodilki work with monochrome sprites, because output attributes up to a pixel in the Y and a very problematic>: -> Before proceeding to the next part of his narrative, I want to tell about how I swap the memory and the screen. ;------------------- Page lister ; In: A-page logic nomber (0 ... 7) ; IF A = # FF THEN GOTO old_pag pager EX AF, AF ' LD A, R JP PE, pg_n_im LD A, R pg_n_im PUSH AF DI EX AF, AF ' AND A JP M, old_pag; A = 0 ... 7 pg_f_op LD (sav_pag), A; for OLD_PAG now_pag EQU $ +1 LD A, 7 LD (old_pag +1), A sav_pag EQU $ +1 LD A, 0 LD (now_pag), a pg_f_sw AND 7; for SCR_SWP pag_or EQU $ +1 OR 0 OUT (# fd), A LD (23388), A POP AF DI RET PO EI RET old_pag LD A, 0 JR pg_f_op ;---------------------- Screen Swaper ; In: A-0 is # 4000, other is # C000 viewing scr_swp EX AF, AF ' LD A, R JP PE, sw_n_im LD A, R sw_n_im PUSH AF DI EX AF, AF OR A LD A, (pag_or) JR NZ, sw_is_7; IF A = 0 THEN scr # 5 RES 3, A sw_f_7 LD (pag_or), A LD A, (now_pag) JR pg_f_sw sw_is_7 SET 3, A JR sw_f_7 ;----------------- # FD mask detecter ; Out: A-Mask for pager fd_mask LD A, # 10 LD BC, # 7ffd OUT (C), A LD HL, # ffff LD E, (HL) LD A, # 50 LD (HL), A OUT (C), A CP (HL) LD A, # 10 OUT (C), A LD (HL), E RET NZ LD A, # 50 RET All of the above procedure shall constitute one package for working with 128 KB. - Proc fd_mask runs one once at the beginning to determine the 512ti kilogram component, if not, click memory enabled the 6 th bit (For the Scorpion). - Proc pager swap to 128 memory remembers the current page now_pag, the previous one in old_pag and all through the swap pag_or. Marazm the register R and the definition of the state of the interrupt is taken from Article Ivan Roshchina, what a huge thanks to him. So makarom I never glitches were to determine the current page. And why did I click on # FD, rather than # 7FFD? Yes, that's like so. - Scr_swp works through the pager, so when I click the memory is not a headache about what to put the mask to the screen. Well now about the INT (interrupt). Ruleznaya very thing that these same interrupt can be hung on them that you want though the whole engine. But it's better to hang things such as scanning buttons and mouse cursor movement (if present), some chips, such as a mini-scroll with HELP, a small animation somewhere in a corner of the screen and, of course, music and effects at the end. When working with the INT may a lot of trouble, all is not even predict, will talk about svoih.V ADV # 10 was given my interrupt handler, similar to sitting in the "Full Shit", in which: - A small percent of the switching visible screen, yuzaet global variables NOW_PAG, PAGE_OR; - Retained the current page number memory and defines the visible screen, is preserved, and then changing variable how_scr; - Cut one page # 7, because it all sitting percent. Keep in mind that INT-table contains 257 bytes and is located in the 2 nd bank to somehow not offend the original Spec. A possible question: "Why is the 7 th bank?" The answer is: yuzayutsya both screens, seats in # 5B00-# BFFF little, and in the seventh minus screen and screen location is as much as 3 kilos. - Restores the screen under the cursor, but if you previously worked switching the visible screen, then the old crap is not restored; - Claudia scanned for pressing the buttons "6,7,8,9,0, Break, Q, A, O, P, Space" and mouse movements (on the PC - Emulsion some golyun with our driver: HRC MUST DIE); - There is recourse to procedure under the name INT_GFX. This is different chips, consists mainly of piles of vectors, which vary depending on the action Gamers, for example: there menyuha, where the object is spinning (it should cut off the bulb on the lamp, and then hang a rotating object, and if you call a pocket the 4-th item; cartoons also played by INT) or dialog box, all on INT by x ..; - Memorized piece at a new location if there was a movement (aka the old) the cursor is drawn, after all the bells and whistles, so as not to fall under any sprite or text; - In the last turn is played for fun and Mouzon change the attributes on traffic lights; - Restoring the memory page variable how_scr and back. The first glitch came when I decided All zaoptimizit: remove my own pct graphics output from the interrupt, so everything was done through a single procedure. And then began ... Began to appear on the screen shit, without any regularity, sometimes even all of the Vistula or cleared. And when everything works without Trace problems. Such bugs hate, because cause once-and not clear. And all the garbage was due to the fact that in the old version vyvodilki saved local variables (The size of a sprite) and in contact with INT they Killy, because INT also yuzal these Proc. CONCLUSION: If the percent yuzayut all, during its operation, all variables must be stored in registers or pushing them into the stack, otherwise the interrupt will have to keep all variables. The second glitch came with switching screens, but this is what I, in my opinion, has spoke ... In general, if all goes well the prog check, the bugs usually occurs small and does not advise to hang on IM 1, although as you like, even though the IM 0, a>: -> Now the structure of "Full Shit", which leaves much to be desired, but that is, on the porridge and boiled ... Can: on / off [T], all process; lock [C] WWWWW INT_MODE 2 BEGIN < > 1.SCR_SWP pass 2.KEY_SCN GO <[T] <3.CR_PROC ^ pass <4.INT_GFX MENU <[T] <5.PLAY_MZ pass n TIME <[C] <o CHK_CNT> [time?] save all and use ^ CLC_WAY CHK_MAP y e V is not no s [Way?]> <[Thing?] V V MAK_WAY RETURN WIN_PUT < TO "BEGIN" use "GO" GO_DRAW ACTIONS ^ ^ < > [Doing] V V V V V V GFX_ENGINE DEATH HAPPY CUT CUT DRAW LOCATION: 1. BACKGROUND 2. HERO 3. UPGROUND 4. TURN ON "SCR_SWP" use many primitive V gfx_procs LOW LEVEL PROCS << V V V VIDEO RAM DISK LOC_MAP 32 * 20 = 640 bytes use it: %%%%%% CAL_WAY - read # # # O ##### O CHK_MAP - read # # # About ###### ACTIONS - read 'write # ######## POYASNILOVA 1) Legend: [T] - threshold (# 0 or # C9); [C] - threshold-counter (skips Th denote n-th number of calls; [Time?] - A condition (eg: time); 2) Podprogi: GO: - per cent, is responsible for mixing generalization of the hero; CLC_WAY - miscalculation of the way, if not, no movement; MAK_WAY - otherwise makes a special pack ravlyayuschy array; GO_DRAW - Work with sprites mixing absorption of Control. array. MENU: - actions with objects; CHK_MAP - checks the status of the cursor on subject or not, " if not, it ignores yuze pa WIN_PUT - otherwise it prompted action and awaits action gamer; ACTIONS - makes the selected action conditions accompanying this business displays a message and anima tion, and according to them makes go to acc. percent if Bo returns to the main cycle. TIME: - constantly redraws u rovoy screen; CHK_CNT - periodically adds time nuyu animation (the bus went out Ball, a hero ...) INT_MODE2 - controls all the processes using the "input threshold" in percent (NOP or RET), SWAPO scans, paints and sings ... GFX_ENGINE - always involved in the processing Scoop the screen or output anything on the screen. LOW LEVEL - utilities, primitives, rabotayuRROCS ing it with the resources of machine Ny. LOC_MAP - an array of size 32 * 20 elements are the maps location. Mainly used characterizes the calculation of ways and work with objects. Now we will calculate the path of the procedure to the map locations for the same asshole that you saw in the "Full Shit ". The algorithm is taken from Glory Mednonogova (Which he, too, where something took, etc. etc.) from his article in one of the ZX-FORMAT 'S. To start better read this article, and then to poke your nose here, because I question, then give the assembler option this method ... I must say that it is up to me turned out to be somewhat problematic, because My siskin (well, a character) has turned out not an element of 1x1, 1x4 and pedryukom. Therefore, I zae just ... Xia grind prog for this asshole, that he somehow ok walked on the location, the more so because of limitations on memory, he could not walk on diagonal. In general, the process of writing this piece of the engine stalled at all the entire process. Okay, here's Generally it-thing: ; (C) DEMON / XPC'99 ;---------------------------; Wawe Algoritm for Search Way ; Main idea V. Mednonogov ; Realized by ME, of course ... s_cod EQU # 50; Start COD gc_mint EQU s_cod +45; MAX Iteration ;---------------- go_wawe RET; Turn LD a, # c9 LD (go_wawe), a ;-------------------- Make Work DIM 34 * 22 = 748 b ; Okantovochka done, so once again do not check out ; Abroad array LD b, 20 LD hl, # 6200; MAP_LOC LD de, gc_wdim +35 gd_lop LD c, H ! ASSM 1932 LDI ! CONT INC de INC de DJNZ gd_lop ;-------------------- Set Fin 'Start inside GO_DIM ; The copied code stake START and GOAL gc_ctar LD bc, 0 LD a, C SUB 4 LD c, A CALL gc_ccrd LD (hl), 128; Target Cod gc_csrt LD bc, 0 LD a, C SUB 4 LD c, A CALL gc_ccrd LD (hl), s_cod; Start Cod INC hl LD (hl), s_cod INC hl LD (hl), s_cod INC hl LD (hl), s_cod LD lx, s_cod ;-------------------- MAIN () gc_main CALL gc_sway JR nz, gc_found DEC a LD (go_way), a; # FF RET ;----------------- Make way ; If found goal ... gc_found EXX LD hl, gcb_way-2 EXX LD c, LX INC lx INC lx LD de, 34 gc_b_lp DEC c CALL gc_lb JR z, gcb_fin CALL gc_rb JR z, gcb_fin CALL gc_db JR z, gcb_fin CALL gc_ub JR z, gcb_fin INC c LD a, LX CP c RET c JR gc_b_lp +1 ;----------------- Found iteration (-1) gcb_fin LD a, B EXX LD (hl), A DEC hl EXX LD (hl), # 81 JR gc_b_lp ;----------------- Make normal way_Map gc_reway POP af LD a, B EXX LD (hl), A LD de, go_way gcrw_lp LD b, (HL) LD a, B CP # ff JR z, gcrw_end CALL gcw_sub LD (de), A INC hl INC de JR gcrw_lp gcrw_end LD (de), A JP rewayer ;----------------- Invert way_step gcw_sub LD a, "L" CP b LD a, "R" RET z CP b LD a, "L" RET z LD a, "U" CP b LD a, "D" RET z LD a, "U" RET ;----------------- Back_search gc_lb LD b, "L" DEC hl LD a, (HL) CP s_cod JR z, gc_reway CP c RET z INC hl RET ;---------------- Gc_rb LD b, "R" INC hl LD a, (HL) CP s_cod JR z, gc_reway CP c RET z DEC hl RET ;---------------- Gc_ub LD b, "U" AND a SBC hl, DE LD a, (HL) CP s_cod JR z, gc_reway CP c RET z ADD hl, DE RET ;---------------- Gc_db LD b, "D" ADD hl, DE LD a, (HL) CP s_cod JR z, gc_reway CP c RET z AND a SBC hl, DE RET ;-------------------- Is Way being? ; If no way then A = 0 gc_sway LD a, LX LD hl, gc_wdim +35 LD bc, 679 gc_cpir CPIR JR z, gc_l1 INC lx LD a, gc_mint CP lx JR nz, gc_sway XOR a RET ;----------------- I_Cod founded gc_l1 PUSH hl, BC DEC hl LD (element), hl CALL gc_left CALL gc_right CALL gc_down CALL gc_up POP bc, HL LD a, LX JR gc_cpir ;-------------------- STEP LEFT gc_left element EQU $ +1 LD hl, 0 DEC hl LD a, (HL) OR a RET p CP 128 JR z, glo_end LD a, LX INC a LD (hl), A RET ;-------------------- STEP RIGHT gc_right LD hl, (element) INC hl gc_v_jr LD a, (HL) OR a RET p CP 128 JR z, glo_end LD a, LX INC a LD (hl), A RET ;-------------------- STEP DOWN gc_down LD hl, (element) LD bc, 1934 ADD hl, BC gcu_jr PUSH hl CALL gc_c_4b POP hl JP m, gc_c_ok RET ;-------------------- STEP UP gc_up LD hl, (element) LD bc, 1934 AND a SBC hl, BC JR gcu_jr ;-------------------- UP or DOWN way is OK! gc_c_ok LD a, 128 EX af, AF ' LD a, LX INC a ! ASSM 4 EX af, AF CP (hl) JR z, glo_end EX af, AF ' LD (hl), A INC hl ! CONT RET ;-------------------- Check 4 bytes gc_c_4b LD a, (HL) INC hl AND (hl) INC hl AND (hl) INC hl AND (hl) RET ;-------------------- It's START!!! glo_end POP de, DE, DE OR a RET ;----------------- In BC-R (X, Y)> Out HL-Adr of ... gc_ccrd INC c INC b LD a, B LD b, C LD hl, gc_wdim gc_mlp LD de, 34 ADD hl, DE DJNZ gc_mlp ADD a, L LD l, A LD a, 0 ADC a, H LD h, A RET ! ASSM! Off ;-------------------- In HL-IL in DIM> Out DE-X, Y gc_c_el LD de, 0 LD bc, 1934 AND a gc_dlp SBC hl, BC JR c, dv_end JR z, dv_end +1 INC e JR gc_dlp dv_end ADD hl, BC LD d, L DEC e DEC d RET ! CONT ;----------------- Very Fatly array gc_wdim DS 748, # 3030 go_way DS 1950, # ffff gcb_way Initially, map location is copied to buffer equal to the size of her own so as not to crap her darling its iterations. As can be seen not armed glance Massively yuzaetsya team CPIR, so I I think soon it turns out, though I did not then optimized, so the time to utrahal itself percent. If you're still bothered read that article, of which I mentioned earlier, then you, my friend, everything will be clear ... Team CPIR looking iteration check her for lice, then look for another and so on until the end of the array. I think everything is clear. When the entire array of processed (blocked crap), we begin the countdown until not arrive at the goal. Done it all pretty mudovo and even evident in the game, although INT, of course, no stopper>: -> The maximum time for the calculation of the path goes away when the path does not exist. Then an array of elements completely 32h20 zamuzhivaetsya and I have it takes as much 13 interruptions, I mean 900,000 strokes! Mudovo ... Since the items on location, I are impassable, then when you specify arrow on them is chosen in advance score coordinates allowable space which can be figured out a way for my asshole. Ie If you choose, for example, Bouncer, the program determines that you chosen subject, and take from the table coordinates for him (or rather for the hero, To approach the subject) and their podsunet rhyme path rather than real coordinates cursor, as it would otherwise. And more ... Percent of walking the hero I was done so that it works through the command (of course only to her, of couse). A special buffer is passed a string of commands to be executed, such as: "L, 1910, U, 2, R, 3, ff" - this is oznachet what to do 10 steps to the left, then 2 up and then 3 steps to the right, # FF - end.Vse simple, but very comfortable now tinkering with the engine under the colored sprites, I just change my values in the Table size of sprites and everything! So do not be surprised values of type "L" or "D" In the above code. Also made by the other procedure, so I beg to wind on the condition ... * So, People, took a lot of time after writing the first part of article, so you can take This is all complete crap. "What does not suck?" - You ask me, my dear friend. All that I or you've done is suck, because Is that what you Already did! And that's something we have not yet can - in essence, is for us an end in itself. There have recently learned that sort of thing - a mask for a sprite can be stored interlaced, ie, two times less! Such a simple and cool idea, but by itself nor hell no come, oh, if earlier know ... For those who do not understand: the masks containing only even or, conversely, odd lines. In the derivation of the shortage is compensated by overlapping lines. All simple - but the sprite is already in 1,5 times less space (eg, $ 16 pounds have cost as much at 6 pounds!). I think this feature has long been known geymmeykeram, but I am personally grateful for VOLGASOFT this idea. You can with this garbage ekskrementirovat somehow, can anyone generally get some rulez. SchA ANT and Vaniac redrawn by zero graphics for FULL SHIT, and because it all the color, then respectively, I encountered some problems ... Sprites are drawn by special- (Fig. 1): Cprayt draws what you want by the Incas and paperami, but the border is not dolzhon use of colors, this allows a square bezel attribute graph turn into a completely acceptable now. Figure 2 shows the essence of the method: All the crap (from the word "crap") begin when all this Tuyev Khuchua pieces should display as a single whole. Here, in principle, there is nothing particularly complicated, but I did this: 1. All the "pieces" are individual sprites, color output as sprite attributes (PUT), and edging as simple (LINES) on OR-method (although and can mask, but the bars to eat more will be, but the effect is not much different). 2. Accordingly, we write (or take) files of sprites to display this format (store and show how can anything, I have this method: 8 lines data, and then for them to line attributes Peninsula 8 lines ...) and make the manager ... 3. "Pieces" of a sprite is stored I have the same array: +0 X, Y (the first one is always on zero) +2 X_SIZE, Y_SIZE 4 The shift to the next MTEF. (NN) 6 Type sprite (ATTR, LINES ... = 0,1 ,...) 7 Sam sprite .. ............ .. ............ + NN X, Y with respect to the very first AB. NN +1 X_SIZE, Y_SIZE ... ... and so on ... Now write the manager who will all of these arrays to rake and decide what to paint next vyvodilkoy "piece" and where to draw it (the translation relative to the actual cords). Clearly, all this will work not as fast as we would like, but first, it is normal, and secondly - optimization knows no bounds! One can already ready-made arrays of the envelope in a different format in a way that does not count for each "piece" cords. I am personally in the scrap, but if tozit, of course, I'll do it ... And so, you can convertible ready arrays of "pieces" so as not to recalculate every time cords for them, okay? Well, to hell, got to write, Bye!
Other articles:
Similar articles:
В этот день... 21 November