added numbers and logo
[zxkeybtest] / testrom.asm
index 5d6ce67..592c7c5 100644 (file)
@@ -3,19 +3,18 @@ fb_addr equ $4000
 attr_addr equ $5800
 ula_port equ $fe
 
+
 main:
        call init
-       ld c, 16
+
+       ld hl, fb_addr + 25
+       call draw_logo
+
+       ld c, 4
        ld b, 12
        call calc_cell_addr
-       ld a, 'F'
-       call putchar
-       inc de
-       ld a, 'O'
-       call putchar
-       inc de
-       ld a, 'O'
-       call putchar
+       ld hl, str_foobar
+       call putstr
 
 .looptop:
        jr .looptop
@@ -82,21 +81,59 @@ calc_cell_addr:
        pop af
        ret
 
+       ; hl: dest
+draw_logo:
+       ld de, logo
+       ld b, 16
+.logoy:        ld c, 7
+       push bc
+.logox: ld a, (de)
+       ld (hl), a
+       inc de
+       inc l
+       dec c
+       jr nz, .logox
+       ld bc, 7
+       sbc hl, bc
+       inc h
+
+       ld a, h
+       and $e7
+       ld h, a 
+       and $7
+       jr nz, .skipinc
+       ld a, l
+       add $20
+       ld l, a
+.skipinc:
+       pop bc
+       dec b
+       jr nz, .logoy
+       ret
 
        ; de: dest
        ; a: char
 putchar:
-       sub 'A'
+       ; is it a digit?
+       ld bc, glyph_0
+       sub '0'
+       ret c
+       cp 10
+       jr c, .common
+       ; is it A-Z ?
+       sub 'A'-'0'
        ret c
        cp 27
        ret nc
+       ld bc, glyph_a
+.common:
        push de
+       push hl
        sla a
        sla a
        sla a
        ld h, 0
        ld l, a
-       ld bc, glyph_a
        add hl, bc
        ld c, 8
 .chartop:
@@ -106,7 +143,31 @@ putchar:
        inc hl
        dec c
        jr nz, .chartop
+       pop hl
        pop de
        ret
 
+       ; de: dest
+       ; hl: str
+putstr:
+       xor a
+       ld b, (hl)
+       cp b
+       jr z, .done
+       ld a, b
+       call putchar
+       inc hl
+       inc de
+       jr putstr
+.done: ret
+
+       ; de: dest
+       ; a: number
+putbin8:
+       ld b, 8
+
+
+str_foobar asciiz 'FOOBAR 1234567890'
+
        include glyphs.inc
+       include logo.inc