(c) 1998 Eraser/Fast Gr./Elders Gr.
Thinking out loud or introduction
When opening this section, I assumed
first of all, to provide assistance in mastering
mash. code for beginners and more experienced coders
ram. Some coders, and most likely lame-
The people who look like coders will protest:
“Well, why! It’s written everywhere!” Whatever
strange, but most people think that the influx
novice coders are over, and there will be
wrong. There is an influx, but only with less
force, and many who have not even yet
dealt with Speck, they are leaving him for the PC
precisely because they are faced with
the aforementioned lamers who do not
understand and do not try to help
help, and sometimes even push them away.
But let's return to the section... It was at first
designed for beginners, but will
probably useful and more or less sophisticated
experienced programmers.
I want to immediately make a reservation about
assemblers. They are all different, of course.
i.e. each of them has its own merits and
its disadvantages:
*GENS 4;
* ZEUS;
* ALASM;
* ZXASM;
* XAS;
* STORM;
* MASM and others that I have not “used”.
The sixth and eighth numbers of the "clubs" were
compiled in ALASM 3.8c, which some
people throw mud at him, but what do they care?
It makes a difference what someone writes on (maybe envy?).
Of course, the listing is given in
ALASM mnemonics.
On this note I will end my statements
about this section and will proceed to
overview of procedures:
Print 42 characters per line.
For high-quality design of your
programs for a good scroller
fast printing of 42 characters required
line. I give several options
print:
;
; Matyushev Alexander
; Slantsy, 1996
; from
; ZX-Review 4-5`1996
;
; Input: the text begins with the TEXT address
; Output: text printing
; Comment: support for control codes:
; print in familiarity X,Y: 22,X,Y
; color printing:
; 16, INK+PAPER*8+BRIGHT*64+FLASH*128,
; having inserted this code (16) procedure
; will put the next number in
; variable ATTR_T (23695)
; and set temporary
;print attributes
ORG 25000; start of the program
LD HL,TEXT
WRITE LD A,(XTXT)
CP 42
JR C,WR2
LD A,(YTXT)
INC A
CP 24
JR C,WR1
XOR A
WR1 LD (YTXT),A
XOR A
LD(XTXT),A
WR2 LD A,(HL)
INC HL
AND A
RET Z
CP 32
JR C,WRIT2
WRIT1 CALL PRSYM
JR WRITE
WRIT2 CP 16
JR NZ,WRITЗ
LD A,(HL)
LD (23695),A
INC HL
JR WR2
WRITЗ CP 22
JR NZ,WRITCH
LD A,(HL)
LD (YTXT),A
INC HL
LD A,(HL)
LD(XTXT),A
INC HL
JR WRITE
WRITCH LD A,"?"
JR WRIT1
PRSYM EXX
PUSH HL
LD L,A
LD H,0ADD HL,HL
ADD HL,HL
ADD HL,HL
LD DE, FONT-256; шрифт
ADD HL,DE
PUSH HL
CHECK LD DE,(XTXT)
LD A,E
ADD A,A
LD E,A
ADD A,A
ADD A,E
LD E,255
LD L,8
CHPL1 INC E
SUB L
JR NC,CHPL1
ADD A,L
LD H,A
LD A,L
SUB H
LD (SL1-1),A
LD (SL2-1),A
ADDRZ LD A,D
AND #18
ADD A,#40
LD H,A
LD A,D
AND 7
RRCA
RRCA
RRCA
ADD A,E
LD L,A
PUSH HL
AADDR LD A,H
RRCA
RRCA
RRCA
AND #03
OR #58
LD H,A
ATTR LD A,(23695)
LD (HL),A
POP HL
POP DE
LD C,8; *
SCRL LD A,(DE)
LD B,0
SL1 SRL (HL)
DJNZ SL1
AND A
LD B,0
SL2 RL A
RL (HL)
DJNZ SL2
INC HL
LD (HL),A
DEC HL
INC H
INC DE
DEC C
JR NZ,SCRL
FINIS LD HL,XTXT
INC (HL)
POP HL
EXX
RET
XTXT DEFB 0
YTXT DEFB 0
TEXT DEFM "Speccy - Rulez"
DEFB 0; конец текста
FONT INCBIN "font"; здесь загрузить
; шрифт
Длина чистого кода 175 байт; старт
процедуры 25000, но можно изменить и на
другой.
Если использоватьcharacter set
6 pixels wide, pressed to the left
upper corner of the familiar place, then you need
change the line marked with an asterisk to
LD C,6.
This printing procedure works very well
slow, but takes up fewer bytes. Her
most advantageous to use where
you have to type small messages,
but no more.
Here is the second version of the print 42 characters
in the line that was applied in ZXC#6:
;
; Especially for Cluba readers
;
; Input: in DE the address of the text. Ex. code <13>
; corresponds to the end of the text, i.e. output
; from the procedure
; Output: text printing
; Comment: support for ex. codes, as in
; previous procedure
;
ORG 25000
LD DE,TXT
CALL PRINT
RET
TXT DEFB 22,1,9,16,1
DEFB "ELDERS GROUP`1998", 13
PRINT LD A,(DE)
INC DE
CP 13
RET ZCP 16
JR Z,COLOR
CP 22
JR Z,AT
CALL rst
JR PRINT
COLOR LD A,(DE)
LD (PERЗ),A
NEXT INC DE
JR PRINT
AT LD A,(DE)
LD (PERЧ),A
INC DE
LD A,(DE)
LD (PER2),A
JR NEXT
CV LD A,L
LD B,A
SRL A
SRL A
LD C,A
ADC A,C
ADD A,C
LD L,A
LD A,H
AND 7
RRCA
RRCA
RRCA
ADD A,L
LD L,A
LD A,H
AND 24
OR 64
LD H,A
PUSH HL
LD A,B
AND 3
ADD A,A
LD L, A
LD H,0
LD BC,PER1
ADD HL,BC
LD C,(HL)
INC HL
LD B,(HL)
POP HL
RET
CVV PUSH HL
PUSH DE
PUSH BC
EX DE,HL
LD L,A
LD H,0
ADD HL,HL
ADD HL,HL
ADD HL,HL
LD BC,FONT-256; шрифт
ADD HL,BC
EX DE,HL
CALL CV
EXX
LD B,8
CVP EXX
LD A,(DE)
BIT 7,B
JR NZ,MUK
RRCA
RRCA
BIT 0,C
JR NZ,MUK
RRCA
RRCA
BIT 3,B
JR NZ,MUK
RRCA
RRCA
MUK EXX
LD C,A
EXX
BIT 0,C
JR NZ,MUK2
LD A,B
CPL
AND (HL)
LD (HL),A
EXX
LD A,C
EXX
AND B
OR (HL)
LD (HL),A
BIT 7,B
JR NZ,MUKЗ
MUK2 INC LLD A,C
CPL
AND (HL)
LD (HL),A
EXX
LD A,C
EXX
AND C
OR (HL)
LD (HL),A
DEC L
MUKЗ INC H
INC DE
EXX
DJNZ CVP
EXX
LD A,H
SUB 8
AND 24
RRCA
RRCA
RRCA
OR 88
LD H,A
LD A,(PERЗ)
BIT 0,C
JR NZ,MUKЧ
LD (HL),A
BIT 7,B
JR NZ,MUKS
MUKЧ INC L
LD (HL),A
MUKS POP BC
POP DE
POP HL
RET
ZXCLUB EXX
LD A,(DE)
INC DE
LD H,0
LD L,A
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,BC
PUSH HL
EXX
DJNZ ZXCLUB
EXX
POP HL
EXX
POP BC
POP DE
POP HL
EXX
PUSH DE
LD B,8
LOOP EXX
LD A,(DE)
INC DE
EXX
RLCA
RLCA
LD D,A
AND 3
EXX
OR (HL)
INC HL
LD (IX+0),A
INC LX
LD A,(BC)
INC BC
EXX
RRCA
RRCA
RRCA
RRCA
LD C,A
AND 15
LD E,A
LD A,D
AND 240
OR E
LD (IX+0),A
LD A,LX
LD D,A
AND 31
CP 31
JR Z,BOL
INC LX
LD A,C
AND 192
LD C,A
LD A,(HL)
INC HL
RRCA
RRCA
OR C
LD (IX+0),A
LDD,LX
DEC LX
BOL DEC LX
INC HX
DJNZ LOOP
LD A,HX
SUB 8
LD HX,A
INC D
LD LX,D
POP DE
POP B.C.
RET
rst PUSH AF
PUSH HL
LD HL,(PER2)
CALL CVV
INC L
LD A,L
CP 42
JR C,HORIZ
LD L,0
INC H
LD A,H
CP 24
JR C,HORIZ
LD H,0
HORIZ LD (PER2),HL
POP HL
POP AF
RET
PER1 DEFB #00,#FC
DEFB #F0,#03
DEFB #C0,#0F,#3F
DEFB #00,#00
PER2 DEFB #11,#16
PERЗ DEFB #00,#00
PERCH EQU $ - 3
DEFS 6
FONT INCBIN "font"; download here
; font
Now let me introduce
turbo driver that was ripped out of the demo
"RAGE". His advantage is enough
fast loading speed, considering that
that the procedure itself “weighs” more than 90
byit. This driver is used in many
demos (RAGE, SčB, OPERA...)
;
; HL - download address
; DE - track/sector
; B - number of sectors to load
;
; Output:
; loading data into memory without processing
; errors and exit, of course
;
ORG 24576
; Example of using the procedure
LD A,(23830); transfer the current one
AND 3; floppy drive from TR-DOS to
LD(DISK),A; turbo loader
; although it wouldn't hurt
; take advantage
; first function
; TR-DOS
LD HL,16384; download address
LD DE,0000; from which track and sector
LD B,27; how many sectors
CALL LOADT; calling the procedure itself
RET
; The turbo loader itself
LOADT PUSH BC
LD C,D
SRL C
LD A,44
JR C,PEREH
LD A,60
PEREH OR 0
DISK EQU $- 1
LD IX,8179; OUT(255),A
CALL DOS
LD A,C
LD C,127
LD IX,10835; OUT(C),A
CALL DOS
LD A,24
LD IX,12227; OUT(31),A
CALL DOS
POP B.C.
PUSH DE
PUSH BC
LD IX,12059
CALL DOS
POP B.C.
POP DE
INC E
INC H
BIT 4,E
JR NZ,SLED
DJNZ LOADT
RET
SLED INC D
LD E,0
DJNZ LOADT
RET
DOS PUSH IX; calling procedures from TR-DOS
JP 15663
P.S. In the next issue of the magazine you will be able
find beautiful windowsprocedures;)
(c) Predator/Fast Group
I completely agree with Eraserom. I yes-
leko is not an assembler monster in itself
I know that I have a lot of good ideas
beginners are overwhelmed by everything they know
machine code barrier. And up to 90
percent is not knowing how to formalize
program even at a primitive level, like
organize at least some kind of interface
with the user. Therefore this section
simply necessary. Famous publications (ZX-
Format, for example), they began to publish
on the topic "Assembler for Beginners", and
why are we worse? Is it really in the glorious city?
Are there any coders in Barnaul? They (good
and not very much) there are, but there are few of them, and new ones
The tributaries are really invisible.
Well, on my own behalf I want to add mine
favorite windows from the cool book "How to
write a game in assembler. Issue 2"
(in case someone doesn’t have it) and the printing procedure
text messages, similar procedure
8252 from ROM, but working every 10 times
faster. Since the symbol seal has been redone
I chose the option using a stack,
then the procedure works every 12-15
faster, which is especially noticeable when walking
chat large volumes of texts. If you, uva-
Dear beginners, have you seen my programs?
(ZX<>BMP converter, Disk Copy), then they could
observe these procedures in action. Voz-
maybe the programs will seem monotonous
decorated, but allthe beauty of these little ones
certain procedures is that they ARE, just simple
valuable workers and do not require any
modifications for a specific program. Osta-
All that remains is to include "window.
a" and draw as many windows as needed
but. By the way, I took the option selector from ZX-
Club #5.
So, the window procedure builds the color -
new window of the required size in the given size
ordinates, and the window is bordered and away from
casts a shadow.
window inc (ix)
inc(ix+1)
ld a,(ix+4)
push af
ld(ix+4),1
call setw
dec (ix)
dec(ix+1)
pop af
ld(ix+4),a
call clsw
call setw
call box
ret
setw ld de,#5800
ld b,(ix+3)
ld c,(ix+2)
ld a,(ix+1)
ld l,a
ld h,0
add hl,hl
add hl,hl
add hl,hl
add hl,hl
add hl,hl
add hl,de
ld a,l
add a,(ix)
ld l,a
ld a,(ix+4)
setw1 push bc
push hl
setw2 ld (hl),a
inc hl
dec c
jr nz,setw2
pop hl
pop bc
ld de,32
add hl,de
djnz setw1
ret
;---------------------------------------
clsw ld b,(ix+3)
ld c,(ix+2)
ld a,(ix+1)
clsw1 push af
push bc
push de
call 3742
pop de
ld a,l
add a,(ix)
ld l,ald b,8
clsw2 push hl
push bc
ld b,c
clswЗ ld (hl),0
inc hl
djnz clswЗ
pop bc
pop hl
inc h
djnz clsw2
pop bc
pop af
inc a
djnz clsw1
ret
;---------------------------------------
box ld a,(ix+1)
push af
call 3742
ld a,l
add a,(ix)
ld l,a
ld b,(ix+2)
box1 ld (hl),255
inc hl
djnz box1
ld b,(ix+3)
pop af
box2 push af
push bc
call 3742
ld a,l
add a,(ix)
ld l,a
ld b,8
boxЗ push hl
ld a,(hl)
or 128
ld (hl),a
ld a,(ix+2)
add a,l
dec a
ld l,a
ld a,(hl)
or 1
ld (hl),a
pop hl
inc h
djnz boxЗ
pop bc
pop af
inc a
djnz box2
dec h
ld b,(ix+2)
boxЧ ld (hl),255
inc hl
djnz boxЧ
ret
Пример использования окошек:
ld ix,winO
call window
ret
winO db 10,0,5,6,1*8+0
Первыйthe parameter specifies X, the second Y,
next is the width and height of the window, and the last one
parameter - window attributes that are calculated
are calculated according to the formula: ink + 8 * paper + 64 *
bright + 128 * flash.
And now the procedure for printing a message. B
in the HL register you need to specify the message address. In
at the end of the message you must put
0. The procedure fully understands the control
The most common ones are: 22, X,Y -
where to display the text; 16, INK - color
text; 17, PAPER - paper color; 18, flag
(0 or 1) - FLASH; 19,flag - BRIGHT; 20,
flag - INVERSE; 21,flag - OVER. Procedure
does not require redefinition of the output channel,
i.e. LD A,2:CALL 5633 is no longer required.
write ld a,(hl)
inc hl
and a
ret z
cp " "
jr c,write2
write1 call prsym
jr write
write2 push hl
push bc
ld hl,table
ldc,a
writeЗ ld a,(hl)
inc hl
and a
jr z,writeS
cp c
jr z,write
inc hl
inc hl
jr writeЗ
writeH pop bc
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
ex(sp),hl
ret
writeS pop bc
pop hl
ld a,"?"
jr write1
pr_13 push hl
ld hl,(23684)
ld a,l
and %11100000
add a,#20
ld l,a
jr nz,pr13_1
ld a,h
add a,8
ld h,a
cp #58
jr c,pr13_1ld h,#40
pr13_1 ld (23684),hl
pop hl
jr write
pr_16 ld a,(hl)
and %111
push bc
ld b,%11111000
pr16_1 ld c,a
ld a,(iy+85)
and b
or c
ld (iy+85),a
pr16_2 pop bc
inc hl
jr write
pr_17 ld a,(hl)
and %111
rlca
rlca
rlca
push bc
ld b,%11000111
jr pr16_1
pr_18 ld a,(hl)
and 1
push bc
ld b,%10111111
pr18_1 rrca
jr pr16_1
pr_19 ld a,(hl)
and 1
push bc
ld b,%10111111
rrca
jr pr18_1
pr_20 ld a,(hl)
and 1
push bc
ld b,%11110111
rlca
rlca
pr20_1 rlca
ld c,a
ld a,(iy+87)
and b
or c
ld (iy+87),a
jr pr16_2
pr_21 ld a,(hl)
and 1
push bc
ld b,%11111101
jr pr20_1
pr_22 ld a,(hl)
cp 24
jr nc,outscr
inc hl
push de
push hl
call 3742
pop de
ld a,(de)
cp 32
jr nc,outscr
inc de
add a,l
ld l,a
ld (23684),hl
pop hl
ex de,hl
jp write
putscr rst 8
db 4
prsym push bc
push de
push hl
ld l,a
ld h,0
add hl,hl
add hl,hl
add hl,hl
ld de,(23606)
add hl,de
ld de,(23684)
ex de,hl
push hl
ld b,8
prs1 ld a,(de)
bit 3,(iy+87)
jr z,prs2
cpl
prs2 bit 1,(iy+87)
jr z,prsЗ
xor (hl)
prsЗ
;--------------------------------------
ld (st2),de
ld (st1),sp
ld sp,#0000
st2 equ $-2
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
inc h
ld sp,(st1)
;--------------------------------------
pop hl
push hl
ld a,h
and #18
rrca
rrca
rrca
add a,#58
ld h,a
ld a,(23695)
ld (hl),a
pop hl
inc l
jr nz,prsЧ
ld a,h
add a,8
ld h,a
cp #58
jr c,prsЧ
ld h,#40
prsЧ ld (23684),hl
pop hl
pop de
pop bc
ret
table
db 13
dw pr_13
db 16
dw pr_16
db 17
dw pr_17
db 18
dw pr_18
db 19
dw pr_19
db 20
dw pr_20
db 21
dw pr_21
db 22
dw pr_22
db 0
st1 dw 0
───────────────────────────────────DI:HALT
Share your thoughts about the article