-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path31-attributes.asm
50 lines (39 loc) · 1.36 KB
/
31-attributes.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
; Example that is used in following article:
; Vývoj her a dem pro ZX Spectrum: vlastní vykreslovací subrutiny
; https://www.root.cz/clanky/vyvoj-her-a-dem-pro-zx-spectrum-vlastni-vykreslovaci-subrutiny/
;
; This article is part of series:
; "Vývoj pro slavné ZX Spectrum"
; https://www.root.cz/serialy/vyvoj-pro-slavne-zx-spectrum/
;
; Repository:
; https://github.com/tisnik/8bit-fame
;
; Example #31:
; Print string using attribute changed directly in memory.
;
; This source code is available at:
; https://github.com/tisnik/8bit-fame/blob/master/Speccy-asm/31-attributes.asm
ENTRY_POINT equ $8000
ROM_OPEN_CHANNEL equ $1601
ROM_PRINT equ $203C
ATTR_T equ 23695
org ENTRY_POINT
start:
ld A,2 ; číslo kanálu
call ROM_OPEN_CHANNEL ; otevření kanálu číslo 2 (screen)
ld B, 64 ; barva tisku
ld HL, ATTR_T ; adresa systémové proměnné ATTR_T
loop:
ld (HL), B ; změna barvy tisku
push BC ; uchovat BC
ld DE, TEXT ; adresa prvního znaku v řetězci
ld BC, TEXT_LENGTH ; délka textu
call ROM_PRINT ; volání subrutiny v ROM
pop BC ; obnovit BC
djnz loop ; tisk další barvou
ret ; ukončit program
; řetězec
TEXT: db "Hello, speccy!"
TEXT_LENGTH: equ $ - TEXT
end ENTRY_POINT