Deja Vu #09
13 ноября 1999 |
|
Coding - how to print 42 characters per line (with trabutami), the procedure is quick print sprites with pixel precision.
(C) D.M0r0Zz __________________________________________ Hello! Theme of today's program: fast printing 42 characters per line, the attributes in this mode, the old songs about scroll'e and rapid withdrawal of sprites with pixel precision (stack free). Let's go! 1. Quick Print 42 characters per line. So, to begin to create three additional font, and each of them will be 2 times larger than the original (4096 bytes each), plus everything else, every of the fonts will follow the sign for the addresses of his characters (512 bytes). This fakingom engaged podproga called CREAT. Call'nut it should at the very beginning, and then may be safely used PRINT, more about which below. Warning: none of the labels can not be held absolutely no semantic load;) FONT EQU BASE ADDRESS FONT FONT2 EQU 49152 FONT3 EQU FONT2 +4096 +512 FONT4 EQU FONT3 +4096 +512 CREAT LD DE, FONT2 LD HL, FONT LD BC, 2048 F_CR1 LD A, (HL) RLCA RLCA AND 3 LD (DE), A INC DE LD A, (HL) RLCA RLCA AND 252 LD (DE), A INC DE INC HL DEC BC LD A, B OR C JR NZ, F_CR1 LD B, 0 LD IX, FONT2 +4096 LD HL, FONT2 LD DE, 16 F_CR11 LD (IX), L INC IX LD (IX), H INC IX ADD HL, DE DJNZ F_CR11 LD HL, FONT LD DE, FONT3 LD BC, 2048 F_CR2 LD A, (HL) RRCA RRCA RRCA RRCA AND 15 LD (DE), A INC DE LD A, (HL) RRCA RRCA RRCA RRCA AND 240 LD (DE), A INC DE INC HL DEC BC LD A, B OR C JR NZ, F_CR2 LD B, 0 LD IX, FONT3 +4096 LD HL, FONT3 LD DE, 16 F_CR21 LD (IX), L INC IX LD (IX), H INC IX ADD HL, DE DJNZ F_CR21 LD BC, 2048 LD HL, FONT LD DE, FONT4 F_CR3 LD A, (HL) RRCA RRCA AND 63 LD (DE), A INC DE LD A, (HL) RRCA RRCA AND 128 64 LD (DE), A INC DE INC HL DEC BC LD A, B OR C JR NZ, F_CR3 LD B, 0 LD IX, FONT4 +4096 LD HL, FONT4 LD DE, 16 F_CR31 LD (IX), L INC IX LD (IX), H INC IX ADD HL, DE DJNZ F_CR31 RET Well, now you can and anything stamped: address text in the HL and boldly call PRINT (screen should be ochishen), whose meaning is that for each character in the shift of familiarity has its own font, IY stores the address of the transition to a conclusion with the necessary displacement. To save time, address "Offset fonts" are taken from previously created tables and sundry can make table and a standard font. PRINT XOR A LD (Y_POZ_ +1), A LD DE, # 4000 LD (S_TBL_ +1), DE LD (SP_I +1), SP LD IX, O1_ LD IY, FUCK1_ ;> Install launch configuration. O1_ LD A, (HL) CP 1933 JP NC, O4_ CP 1932 JP NZ, O9_ ; ; If blank, then immediately go to the next; schemu symbol ; INC HL EX DE, HL LD A, LY CP FUCK1_ '& ampL JP Z, O11_ LD HL, S_TBL_ +1 INC (HL) O11_ LD A, LY CP FUCK1_ '& ampL LD IY, FUCK2_ JP Z, O111_ CP FUCK2_ '& ampL LD IY, FUCK3_ JP Z, O111_ CP FUCK3_ '& ampL LD IY, FUCK4_ JP Z, O111_ LD IY, FUCK1_ O111_ EX DE, HL JP (IX) ; ; Style design METKA '& ampL means that ; Taken the low byte address METKA. ; O9_ CP # 0D; transition to sled.stroku JP Z, Y_POZ_ CP 3; end of the text JP Z, SP_I INC HL CP # 10; feature attributes JR NZ, O1_ INC HL JP (IX) O4_ INC HL EXX LD L, A LD H, 0 S_TBL_ LD DE, 0 JP (IY) ; ; Shift 2 bits from the start of familiarity ; FUCK4_ LD IY, FUCK1_ LD BC, FONT4 +4096 JP FUCK0_ ; ; Shift 4 bits from the beginning znakometsa ; FUCK3_ LD IY, FUCK4_ LD BC, FONT3 +4096 JP FUCK0_ ; ; Shift of 6 bits from the start of familiarity ; FUCK2_ LD IY, FUCK3_ LD BC, FONT2 +4096 FUCK0_ ADD HL, HL ADD HL, BC LD SP, HL POP HL LD SP, HL EX DE, HL POP DE LD A, E OR (HL) LD (HL), A INC L LD (HL), D INC H POP DE LD (HL), D DEC L LD A, E OR (HL) LD (HL), A INC H POP DE LD A, E OR (HL) LD (HL), A INC L LD (HL), D INC H POP DE LD (HL), D DEC L LD A, E OR (HL) LD (HL), A INC H POP DE LD A, E OR (HL) LD (HL), A INC L LD (HL), D INC H POP DE LD (HL), D DEC L LD A, E OR (HL) LD (HL), A INC H POP DE LD A, E OR (HL) LD (HL), A INC L LD (HL), D INC H POP DE LD (HL), D DEC L LD A, E OR (HL) LD (HL), A LD HL, S_TBL_ +1 INC (HL) EXX JP (IX) ; ; Character output without bias ; FUCK1_ ADD HL, HL ADD HL, HL ADD HL, HL LD BC, FONT ADD HL, BC LD SP, HL EX DE, HL POP DE LD (HL), E INC H LD (HL), D INC H POP DE LD (HL), E INC H LD (HL), D INC H POP DE LD (HL), E INC H LD (HL), D INC H POP DE LD (HL), E INC H LD (HL), D LD IY, FUCK2_ EXX JP (IX) ; ; Address calculation sled.linii.Standartno. ; Y_POZ_ LD A, 0 CP 1923 JP Z, SP_I INC A LD (Y_POZ_ +1), A EX DE, HL LD B, A AND # 18 ADD A, # 40 LD H, A LD A, B AND 7 RRCA RRCA RRCA LD L, A LD (S_TBL_ +1), HL EX DE, HL INC HL LD IY, FUCK1_ JP (IX) SP_I LD SP, 0 RET 2. Set the attributes on the screen with fonts that in 42 characters per line. LD DE, # 5800 LD BC, TEXT_ADRES; LD A, 68; default attribute LD (A_CC +1), A A_S0 LD HL, A_TABLE A_S1 LD A, (BC) INC BC CP 1932 JR NC, A_K CP 3; CODE END OF TEXT RET Z CP # 0D; CODE END OF LINE JR Z, A_N CP # 10; attribute code JR Z, A_C A_K LD A, E EX AF, AF LD A, E ADD A, (HL) LD E, A A_CC LD A, 0 LD (DE), A EX AF, AF LD E, A INC HL JR A_S1 A_C LD A, (BC) LD (A_CC +1), A INC BC JR A_S1 A_N LD A, E EX AF, AF LD A, E ADD A, (HL) LD E, A LD A, (A_CC +1) LD (DE), A EX AF, AF LD E, A LD HL, # 20 ADD HL, DE EX DE, HL LD A, D CP # 5B JR C, A_S0 RET A_TABLE DB 0,0,1,2,3,3,4,5,6,6,7 DB 8,9,9,10,11,12,12,13,14 DB 15,15,16,17,18,18,19,20 DB 21,21,22,23,24,24,25,26 DB 27,27,28,29,30,30,31,31 This procedure creates a similar to shift the screen down on a familiarity. ADRES EQU # 4000; address from which we ; Shifts N EQU 24; NUMBER scrollable ; LINES KUDA EQU # C000; where to put PROCEDURE LD IX, KUDA LD DE, ADRES +16 LD HL, ADRES + # 20 LD B, N * 8 LD (IX), # F3; DI INC IX LD (IX), # ED INC IX LD (IX), # 73 INC IX INC IX INC IX; LD (NNNN), SP CKL1 PUSH HL, DE CALL SETS CALL SETS POP DE, HL CALL DN_DE; STANDARD Proc CALL DN_HL; fools to find DJNZ CKL1; SLED.POZITSII ; For quick Scroll ATTRIBUTES And it should be changed address, Remove "* 8" FRONT ; N and replace "Kala" at finding a trace. ; POSITION Attributes LD (IX), # 31 INC IX LD (KUDA +3), IX INC IX INC IX LD (IX +0), # FB; EI LD (IX +1), # C9; RET RET SETS LD (IX +0), # 31 LD (IX +1), L LD (IX +2), H LD (IX +3), # F1 LD (IX +4), # C1 LD (IX +5), # D1 LD (IX +6), # E1 LD (IX +7), # D9 LD (IX +8), # C1 LD (IX +9), # D1 LD (IX +10), # E1 LD (IX +11), # DD LD (IX +12), # E1 LD (IX +13), # 31 LD (IX +14), E LD (IX +15), D LD (IX +16), # DD LD (IX +17), # E5 LD (IX +18), # E5 LD (IX +19), # D5 LD (IX +20), # C5 LD (IX +21), # D9 LD (IX +22), # E5 LD (IX +23), # D5 LD (IX +24), # C5 LD (IX +25), # F5 PUSH BC LD BC, 16 ADD HL, BC EX DE, HL ADD HL, BC EX DE, HL LD BC, 26 ADD IX, BC POP BC RET Similarly, we can get the scroll in the opposite direction. 3. Quick conclusion sprite up pixel. My proposed algorithm differs from all previously published the fact that before Begin the table is created (and where did without them) with a length of 256 bytes (that is how much different combinations of bits contained in 1 byte), the tables are stored halves shifted bytes. Example of creating a pair of these tables for Print sprite with a shift in the 2-bit bytes from the beginning ("ld" free;)). SM2_1 EQU # C000 SM2_2 EQU # C100 ; Tables should go with a flat addresses 1 per And another for kazhdogosdviga need 2 ; Table t.k.bayt divided into 2 pieces. HL, SM2_1 DE, SM2_2 C, 0 CREAT A, C SRL A; shift for the first half SRL A; right by 2 bits (HL), A A, C SLA A; second part will be shifted SLA A; a 6-bit to the left. SLA A SLA A SLA A SLA A (DE), A INC HL INC DE INC C JR NZ, CREAT Similarly, you can get the other shifts. Generally, it is not necessary print with pixel accuracy, in many cases, excellent results are obtained at step 2 pixels. An example of "naked" horizontal printing line sprite 2-byte offset 2 bits (bc-address in the screen, de-a sprite). A, (DE); took byte sprite L, A; in hl obtain location H, SM2_1 '&H; shifted to the right bytes A, (HL); took ... (BC), A; put ... INC L; sled.znakomesto ... INC H; moved to table the "Left" ; Shifts. A, (HL); took ... (BC), A; put ... INC DE; sled.bayt sprite DEC H; again switched to the original ; Table. A, (DE); took byte sprite L, A; and were shifted version A, (BC); the same ... OR (HL) (BC), A INC H INC C A, (HL) (BC), A etc. I hope you get the point;). As we see, pretty decent speed, even without using the stack. P.S. I have tried several times to go after Xas'a in Alasm, but then LD forget to dial, then click on EDIT at the disc draws me to sleep, and instead of "#" persistently put the point ... Help, good people;). WARNING WARNING !!!!! Anyone who wants to get me angry hitting and what would his treacherous crime knew then all the poor provincial Yousser, write!
Other articles:
Similar articles:
В этот день... 23 November