Aspect #06
10 февраля 1998 |
|
Programming - Corrected procedure MAKE OUT.
First of all, to inform all those who have used procedure MAKEOUT, that it found error, that's corrected text of procedure: ; LOGIN: ; HL - address of a procedure OUTPUT ; D - TOP POSITION ON Y ; E - LEFT POSITION ON X ; B - HEIGHT Virtual Screen , (In the text coordinates) ; C - LENGTH OF VIRTUAL SCREEN / 2 , (Also in TEKSTVYH coordinates) ; OUTPUT: NO MAKOUT LD (HL), # 21 XOR A DUP 2 INC HL LD (HL), A EDUP INC HL LD (HL), # 39 INC HL LD (HL), # EB INC HL LD (HL), # F9 INC HL MAKOUT1 PUSH DE LD A, D DUP 3 RRCA EDUP AND # E0 ADD A, E LD E, A LD A, D AND # 18 OR # 40 LD D, A LD A, 8 MAKOUT2 PUSH BC PUSH DE MAKOUT3 LD (HL), # E1 INC HL LD (HL), # 22 INC HL LD (HL), E INC HL LD (HL), D INC HL INC E; <- there was only one INC E INC E DEC C JR NZ, MAKOUT3 POP DE POP BC INC D DEC A JR NZ, MAKOUT2 POP DE INC D DJNZ MAKOUT1 LD (HL), # EB INC HL LD (HL), # F9 INC HL LD (HL), # C9 RET Well, as promised tepericha procedure O 16 * 12 sprites on the screen, ie, on-screen sprite will be four 16 * 12: ORG # 61A8 CALL ZAPTAB; fill in the address table CALL ZAPOLN; make the procedure for deriving DI LD DE, SPRADRES; address of your sprite CALL SPEEDOUT; taking it EI RET ; Doing here PROCEDURE OUTPUT ZAPOLN LD HL, SPEEDOUT LD BC, # 0C00; Height 12 LD (HL), # 21; LD HL, 0 INC HL LD (HL), C INC HL LD (HL), C INC HL LD (HL), # 39; ADD HL, SP INC HL LD (HL), # EB; EX DE, HL INC HL LD (HL), # F9; LD SP, HL INC HL CALL ZAPOUT; FILLS THE PROCEDURE FOR WITHDRAWAL LD (HL), # EB; EX DE, HL INC HL LD (HL), # F9; LD SP, HL INC HL LD (HL), 201; RET RET ; B-HEIGHT SCREEN IN TEKST.KOORDINATAH ; C-STARTING POSITION ON VERYIKALI ; HL-ADDRESS PROCEDURE OUTPUT ZAPOUT LD IX, TABLE; address table in the IX DI PUSH IY LD IY, TABLE; SAME BUT IY LD E, C LD D, 0 EX DE, HL; HL = HL * 8 ADD HL, HL ADD HL, HL ADD HL, HL ADD HL, HL EX DE, HL ADD IX, DE; INITIAL ADDRESS IN TABLE ADD IY, DE LD DE, 192; Offsets AT POLEKRANA ADD IY, DE LD E, D; DE = 0 ZAPOUT3 ADD IX, DE; GO TO THE NEXT ADD IY, DE; LINE LD E, (IX) LD D, (IX +1) PUSH DE LD (__DE), DE LD E, (IY) LD D, (IY +1) LD C, 8, 8 bytes into characters ZAPOUT1 PUSH DE LD A, 8 ZAPOUT2 LD (HL), # E1; POP HL INC HL LD (HL), # 22; LD (ADDR1), HL INC HL LD (HL), E INC HL LD (HL), D INC HL EX AF, AF '; CONCLUSION In the next quarter LD A, E; SCREEN ADD A, # 10, 16 LD E, A LD (HL), # 22; LD (ADDR1 +16), HL INC HL LD (HL), E INC HL LD (HL), D INC HL SUB # E; -14 =- 16 +2 LD E, A LD (_DE), DE LD DE, (__DE); SAME ... LD (HL), # 22; LD (ADDR2), HL INC HL LD (HL), E INC HL LD (HL), D INC HL LD A, E ADD A, # 10, 16 LD E, A LD (HL), # 22; LD (ADDR2 +16), HL INC HL LD (HL), E INC HL LD (HL), D INC HL SUB # E; -14 =- 16 +2 LD E, A LD (__DE), DE LD DE, (_DE) EX AF, AF ' DEC A JR NZ, ZAPOUT2; AND SO 8 times ... POP DE INC D LD (__DE), DE EX DE, HL EX (SP), HL EX DE, HL INC D DEC C JR NZ, ZAPOUT1; so too 8 times ... POP DE LD DE, 16 DJNZ ZAPOUT3; GO TO NEXT LINE POP IY EI RET _DE DEFW 0 __DE DEFW 0 , Filling the address table ZAPTAB LD IX, TABLE LD HL, # 4000 CALL ZAPADR LD HL, # 4800 CALL ZAPADR LD HL, # 5000 CALL ZAPADR LD (IX), # FF LD (IX +1), # FF LD (IX +2), # FF RET ZAPADR LD DE, # 20 LD C, 8 ZAPAD2 PUSH HL LD B, 8 ZAPAD1 LD (IX), L LD (IX +1), H INC IX INC IX INC H DJNZ ZAPAD1 POP HL ADD HL, DE DEC C JR NZ, ZAPAD2 RET TABLE DEFS 5000 SPEEDOUT Actually, similar procedures are built to display sprites 2 * 2,4 * 4 8 * 8, etc. By the way sprites can be displayed not manufacturing procedures vyvoda.Vot, for example, procedure code deducing two sprites in staggered in the third screen, sprites size 4 * 4: ; BC - ADDRESS 1 ST Sprite ; DE - ADDRESS 2-GO Sprite ; HL - address of the third SCREEN SPROUT LD (SPROUT1 +1), BC DI LD (SPROUT2 +1), DE LD (SPSAVE +1), SP; stores a pointer STACK LD DE, # 0800; OUT WITH THE END OF THIRD SCREEN ADD HL, DE LD (SPROUT3 +1), HL LD DE, - # 80; HALF THE THIRD SCREEN ADD HL, DE LD (SPROUT4 +1), HL LD D, H LD E, # 20; SHIFT ON LINE LD C, 4 SPROUT5 LD B, 8, 8 bytes into characters NEXTSPP EXX; THAT NEED SOHRANYAME BUT EX AF, AF ' SPROUT1 LD SP, 00; HERE TO ADDRESS Sprite POP AF; take the data POP BC LD (SPROUT1 +1), SP; Save position SPROUT2 LD SP, 00; Similarly, for the 2 nd Sprite POP DE POP HL LD (SPROUT2 +1), SP SPROUT3 LD SP, 0; ADDRESS OUTPUT DUP 4 PUSH DE; CLADEM DATA IN CHESS PUSH HL; ORDER PUSH AF PUSH BC EDUP SPROUT4 LD SP, 0; SAME BUT DIFFERENT DUP 4; HALF third of the screen PUSH AF PUSH BC PUSH DE PUSH HL EDUP EX AF, AF ' EXX; RESTORES LD A, (SPROUT3 +2); ALL THE ABOVE DEC A; higher and higher LD (SPROUT3 +2), A LD A, (SPROUT4 +2) DEC A LD (SPROUT4 +2), A DJNZ NEXTSPP LD HL, (SPROUT4 +1) LD H, D LD A, L SUB E LD L, A LD (SPROUT4 +1), HL LD A, (SPROUT3 +1) SUB E LD L, A LD (SPROUT3 +1), HL DEC C JP NZ, SPROUT5 SPSAVE LD SP, 0; RESTORES STACK EI RET And here is an example of appeal to her: LD HL, # 4800; seredinke SCREEN LD DE, SPR1 LD BC, SPR2 CALL SPROUT Hmm, well tepericha I'll show you another joke the procedure faster graphics: ORG # 61A8 LD HL, # 4000 blank screen LD DE, # 4001 LD BC, 6144 LD (HL), L LDIR LD BC, 767; INK 7: PAPER 0: BRIGHT 1 LD (HL), 71 LDIR LD HL, 15616; jeer FONTAINE LD DE, FONT LD BC, 768 PUSH DE LDIR POP HL PUSH HL LD BC, # 6060 PREOBR1 PUSH BC SUB A LD B, A SET 2, B DUP 4 INC HL EDUP PREOBR2 LD A, (HL) LD C, A SLA A OR C LD (HL), A INC HL DJNZ PREOBR2 POP BC DJNZ PREOBR1 POP HL LD (FONT32 +1), HL LD HL, # C000; pure virtual SCREEN LD DE, # C001 LD BC, # 4000 LD (HL), 0 LDIR LD HL, # C600; INITIAL POSITION LD (INT3 +1), HL LD HL, SPEED; BUILD procedure for deriving LD DE, # 800; Y = 8, X = 0 LD BC, # 1010; At the height of 16, and at length 32! CALL MAKOUT LD HL, INTERR; puts his PROCESSOR CALL IMON; UNINTERRUPTED LD HL, TEXT0; print TEXT in 2-nd LD DE, # C820; HALF VIRT.EKRANA LD C, # 20; SLESCHENIE CALL VIRTWRITE; PROCEDURE FOR WITHDRAWAL OF TEXT LD A, # 1C; ON VIRT. SCREEN PUSH AF; all kinds INSTALLATION PUSH HL LD (INT4), A LD A, C LD (INT5 +1), A LD A, 1 LD (INT1 +1), A WAITER EI; WAITING Buttons HALT LD A, # 7F; ethno SPACE IN A, (# FE) BIT 0, A JR Z, WAITER1 LD A, # BF; THIS IS A ENTER IN A, (# FE) BIT 0, A JP NZ, WAITER LD A, C; VARIES Half VIRT.EKRANA XOR # 20 LD C, A LD E, A LD D, # C8 CALL VIRTCLEAR; PURE Half POP HL LD A, (HL); if 1 TO END OF TEXT DEC A JP NZ, WAITER2 LD HL, TEXT0; And if the end of the text, ; SHOULD GO TO TOP WAITER2 CALL VIRTWRITE; PRINT POP AF XOR 1 PUSH AF PUSH HL LD (INT4), A; Resets LD A, C LD (INT5 +1), A LD A, 1 LD (INT1 +1), A LD B, 33; WAIT UNTIL THE SCREEN DOES NOT APPEAR WAITER0 EI HALT DJNZ WAITER0 JR WAITER WAITER1 POP HL; END POP AF; crowns DI; RESTORES THE INTERRUPTION LD A, 63 LD I, A IM 1 EI RET; EXIT C ; PROCEDURE OF ITS UNINTERRUPTED ; INLET HL - address of the procedure PROCESSING IMON DI LD A, 24; JR 65524 LD (65535), A LD A, 195; JP ADDR LD (65524), A LD (65525), HL LD HL, # FE00; ethno FOR Jump INTA LD DE, # FE01 LD BC, 256 LD A, H LD (HL), # FF LDIR DI LD I, A IM 2 EI RET ; Interrupt servicing routines INTERR PUSH AF; RESERVED PUSH HL PUSH DE PUSH BC INT1 LD A, 0; I allowed to move? AND A INT3 LD DE, 0 JR Z, INT7 INT4 INC E; Yes, allow => MOVE INT7 LD HL, 128; Shifts 4 pixels ADD HL, DE EX DE, HL LD (INT3 +1), DE LD A, E AND # 3F; we reached the goal? INT5 CP # 20 JP NZ, INT6 XOR A; YES, move more NOT NADA! LD (INT1 +1), A INT6 LD A, D INT8 CP # C8 JP NZ, INT9 LD A, (INT7 +2) XOR # FF LD (INT7 +2), A LD A, (INT8 +1) XOR 12 LD (INT8 +1), A INT9 CALL SPEED; The-C POP BC POP DE POP HL POP AF EI RET ; CLEANING OF A VIRTUAL SCREEN ; INLET DE - Half ADDRESS VIRTCLEAR PUSH DE PUSH BC LD BC, # 8020; At the height 128, length 32 EX DE, HL LD E, # 20; OFFSET LD D, 0 VIRTC1 PUSH BC VIRTC2 LD (HL), D INC HL DEC C JP NZ, VIRTC2 ADD HL, DE POP BC DJNZ VIRTC1 POP BC POP DE RET ; CONCLUSION text on the VIRT. SCREEN ; LOG HL - TEXT OF ADDRESS ; DE - ADDRESS Half VIRT.EKRANA ; C - offset 0 or 32 VIRTWRITE LD A, (HL); TAKE character code INC HL AND A; END OF TEXT? RET Z; YES! CP # 0D; Newlines JR Z, VIRTWR1; YES! CALL PRSYM; outputs the character LD A, E; REACHING THE END OF THE LINE AND # 1F CP # 1F JR Z, VIRTWR1; gotten to ... INC E JP VIRTWRITE; still ahead! VIRTWR1 INC D; DO INC D TWICE INC D; TK WE HAVE TWO SCREEN LD E, C JP VIRTWRITE; WILL C ; Character output ON VIRT.EKRAN PRSYM PUSH HL PUSH BC PUSH DE SUB # 20 FONT32 LD DE, 15616; HERE TO ADDRESS FONT LD L, A LD H, 0 ADD HL, HL ADD HL, HL ADD HL, HL ADD HL, DE LD C, L LD B, H POP HL PUSH HL LD DE, # 40 DUP 8 LD A, (BC) INC BC LD (HL), A ADD HL, DE EDUP POP DE POP BC POP HL RET ; LOGIN: ; HL - address of a procedure OUTPUT ; D - TOP POSITION ON Y ; E - LEFT POSITION ON X ; B - HEIGHT Virtual Screen , (In the text coordinates) ; C - LENGTH OF VIRTUAL SCREEN / 2 , (Also in TEKSTVYH coordinates) ; OUTPUT: NO MAKOUT LD (HL), # 21; LD HL, 0 XOR A DUP 2 INC HL LD (HL), A EDUP INC HL LD (HL), # 39; ADD HL, SP INC HL LD (HL), # EB; EX DE, HL INC HL LD (HL), # F9; LD SP, HL INC HL MAKOUT1 PUSH DE LD A, D DUP 3 RRCA EDUP AND # E0 ADD A, E LD E, A LD A, D AND # 18 OR # 40 LD D, A LD A, 8 MAKOUT2 PUSH BC PUSH DE MAKOUT3 LD (HL), # E1; POP HL INC HL LD (HL), # 22; LD (ADDR), HL INC HL LD (HL), E INC HL LD (HL), D INC HL INC E INC E DEC C JR NZ, MAKOUT3 LD (HL), # 21; LD HL, # 20 INC HL LD (HL), # 20 INC HL LD (HL), C INC HL LD (HL), # 39; ADD HL, SP INC HL LD (HL), # F9; LD SP, HL INC HL POP DE POP BC INC D DEC A JR NZ, MAKOUT2 POP DE INC D DJNZ MAKOUT1 LD (HL), # EB; EX DE, HL INC HL LD (HL), # F9; LD SP, HL INC HL LD (HL), # C9; RET RET ; Text to FORMAT: ; Any character, # 0D - newline ; 0 - END OF PAGE 1 END OF TEXT TEXT0 DEFS 32, "+" DEFB "+ +" DEFB "+ HELLO SPBZXNET!!! +" DEFB "+ +" DEFB "+ TRSOFT PRESENT +" DEFB "+ +" DEFB "+ THIS MOVING TEXT +" DEFB "+ +" DEFB "+ TO EXIT PRESS SPACE +" DEFB "+ +" DEFB "+ AND PRESS ENTER TO NEXT PAGE +" DEFB "+ +" DEFB "+ +" DEFS 32, "+" DEFB 0 DEFB "H H EEEE L L OO" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "HHHH EEE L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H E L L O O" DEFB "H H EEEE LLLL LLLL OO" DEFB 0,1,1 FONT DEFS 768 SPEED Ponayali why such speed? Yes it is very Easy! The text will not move and do not scrolls, only address changes in procedure output, and change the address of a much shorter and faster than a scrolled and sdvigat.Vot another example: ORG # 61A8 LD HL, SPEED; makes the procedure OUTPUT LD DE, # 400 LD BC, # 0F10 CALL MAKOUT LD HL, # C000; PURE VIRT.EKRAN LD DE, # C001 LD BC, # 3FFF LD (HL), 0 LDIR LD HL, # 4000 blank screen LD DE, # 4001 LD BC, 6143 LD (HL), 0 LDIR LD HL, # 5800; Sets attributes LD DE, # 5801 LD BC, 767 LD (HL), 71 LDIR LD HL, INTERR; puts his PROCESSOR CALL IMON; UNINTERRUPTED LD HL, TEXT; print TEXT LD DE, # D000; Teletype LD C, 0 LD B, C CALL T_TAPE XOR A LD (23560), A MECH EI HALT LD A, (23560) JR Z, MECH RET ; The printing TTY T_TAPE LD A, (HL); END OF TEXT? INC HL AND A JR Z, T_TAPE0; YES! CP # 0D; Newline? JR Z, NEXTLINE0; YES! CALL PRINS; character output INC E LD A, E BIT 5, E JR Z, T_TAPE1 JR NEXTLINE T_TAPE0 LD A, 32; Overwrite CURSOR CALL PRINS RET; AND EXIT NEXTLINE0 LD A, 32; Overwrite CURSOR CALL PRINS NEXTLINE INC D INC D INC D LD E, C T_TAPE1 LD A, "@"; OUTPUT CURSOR CALL PRINS EI HALT; WAIT-S HALT HALT JR T_TAPE ; Interrupt servicing routines INTERR DI PUSH HL PUSH DE PUSH AF INT1 LD HL, # D000; INITIAL POSITION INT0 LD A, 1 DEC A LD (INT0 +1), A JP NZ, INT3 LD A, 1 LD (INT0 +1), A INT2 INC H; scroll the LD (INT1 +1), HL LD A, H INT4 CP # E0; up to certain limits JP NZ, INT3; COURSE LD A, (INT2) XOR 1 LD (INT2), A LD A, (INT4 +1) XOR 32 LD (INT4 +1), A INT3 EX DE, HL CALL SPEED; CONCLUSIONS POP AF POP DE POP HL EI RET PRINS PUSH HL PUSH BC PUSH DE SUB # 20 LD L, A LD H, 0 ADD HL, HL ADD HL, HL ADD HL, HL LD DE, 15616 ADD HL, DE EX DE, HL POP HL PUSH HL LD C, E LD B, D LD DE, 32 DUP 8 LD A, (BC) INC BC DUP 2 LD (HL), A ADD HL, DE EDUP LD (HL), D ADD HL, DE EDUP POP DE POP BC POP HL RET ; Well, THIS PROCEDURE OF CONSTRUCTION PROCEDURES ; OUTPUT! ; LOGIN: ; HL - address of a procedure OUTPUT ; D - TOP POSITION ON Y ; E - LEFT POSITION ON X ; B - HEIGHT Virtual Screen , (In the text coordinates) ; C - LENGTH OF VIRTUAL SCREEN / 2 , (Also in TEKSTVYH coordinates) ; OUTPUT: NO MAKOUT LD (HL), # 21; LD HL, 0 XOR A DUP 2 INC HL LD (HL), A EDUP INC HL LD (HL), # 39; ADD HL, SP INC HL LD (HL), # EB; EX DE, HL INC HL LD (HL), # F9; LD SP, HL INC HL MAKOUT1 PUSH DE LD A, D DUP 3 RRCA EDUP AND # E0 ADD A, E LD E, A LD A, D AND # 18 OR # 40 LD D, A LD A, 8 MAKOUT2 PUSH BC PUSH DE MAKOUT3 LD (HL), # E1; POP HL INC HL LD (HL), # 22; LD (ADDR), HL INC HL LD (HL), E INC HL LD (HL), D INC HL INC E INC E DEC C JR NZ, MAKOUT3 POP DE POP BC INC D DEC A JR NZ, MAKOUT2 POP DE INC D DJNZ MAKOUT1 LD (HL), # EB; EX DE, HL INC HL LD (HL), # F9; LD SP, HL INC HL LD (HL), # C9; RET RET ; NO COMMENTS IMON DI LD A, 24 LD (65535), A LD A, 195 LD (65524), A LD (65525), HL LD HL, # FE00 LD DE, # FE01 LD BC, 256 LD A, H LD (HL), # FF LDIR DI LD I, A IM 2 EI RET TEXT DEFS 32, "*" DEFB "* HELLO SPBZXNET!!!" DEFB "*" DEFB "* WRITTEN BY TRUSOV ILYA" DEFB "*" DEFS 32, "*" DEFB 0 SPEED Yes, do not get that so you can makarom display only monochrome images, with color can do absolutely as well. Incidentally the same makarom can be arranged scroller - ie, the text first, fully appears and then when you click on the button only changing the address on the virtual screen. So that scrolling is oochen quickly. By the way you can build a derivation with the commands LD and PUSH: ; PROCEDURE FOR WITHDRAWAL Sprite 2X1 2 / 3 ; SCREEN BOTTOM ; The figures in INPUT: DE - Sprite ADDRESS + 16 ; The figures in HOLIDAY: NO P2X2 LD HL, # 5800; Conclusion Lower third LD (P2X2_0 +1), HL LD H, # 50; CONCLUSION In the second third LD (P2X2_1 +1), HL EX DE, HL LD (P2X2_4 +1), SP; stores a pointer to the stack LD A, 8, EIGHT bytes into characters DEC HL P2X2_3 LD D, (HL); TAKE INITIAL DATA DEC HL LD E, (HL) DEC HL P2X2_0 LD SP, 0 DUP 128; CONCLUSIONS PUSH DE EDUP LD (P2X2_0 +1), SP P2X2_1 LD SP, 0 DUP 128, and again, but in other parts PUSH DE EDUP LD (P2X2_1 +1), SP DEC A JP NZ, P2X2_3 P2X2_4 LD SP, 0 RET Well, actually, it's time to fast graphics finish: basic principles you know and further, you izvraschatsa as your heart desires and even to infinity ... (C) Trusov Ilya
Other articles:
Similar articles:
В этот день... 21 November