From 4ecc5df01ba5c77c1aa89429ae93fc4facb4c98f Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 10 Feb 2020 02:32:11 +0200 Subject: [PATCH] done --- Makefile | 5 +- glyphs.inc | 55 ++++++++++++++++++ testrom.asm | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 213 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 501cb6f..8e85c12 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ ASFLAGS = -Fvobj LD = vlink LDFLAGS = -b rawbin1 +.PHONY: all +all: tap rom + .PHONY: tap tap: $(tap) @@ -40,4 +43,4 @@ run: $(tap) .PHONY: program program: $(rom) - minipro -p 'AT28C16 @DIP24' -s -w $< + minipro -p 'AT28C16E @DIP24' -s -w $< diff --git a/glyphs.inc b/glyphs.inc index a464d6c..fac27f1 100644 --- a/glyphs.inc +++ b/glyphs.inc @@ -89,6 +89,15 @@ glyph_9: db %01000100 db %00111000 db %00000000 +glyph_colon: + db %00000000 + db %00000000 + db %00010000 + db %00000000 + db %00000000 + db %00010000 + db %00000000 + db %00000000 glyph_a: db %00010000 db %00101000 @@ -323,3 +332,49 @@ glyph_z: db %01000010 db %11111110 db %00000000 + +glyph_caps: + db %01100000 + db %10000000 + db %10000000 + db %10000111 + db %01101000 + db %00000110 + db %00000001 + db %00001110 +;glyph_spc: +; db %01100000 +; db %10000000 +; db %01011000 +; db %00110101 +; db %11011010 +; db %00010010 +; db %00010010 +; db %00000001 +glyph_spc: + db %00000000 + db %00000000 + db %00000000 + db %00000000 + db %00000000 + db %00000000 + db %10000001 + db %11111111 +glyph_symb: + db %01100000 + db %10000000 + db %01100000 + db %00010110 + db %11101000 + db %00000110 + db %00000001 + db %00001110 +glyph_enter: + db %00000000 + db %00000000 + db %00100001 + db %01100001 + db %11111111 + db %01100000 + db %00100000 + db %00000000 diff --git a/testrom.asm b/testrom.asm index 592c7c5..55d1bfe 100644 --- a/testrom.asm +++ b/testrom.asm @@ -1,27 +1,83 @@ ; vi:filetype=z80: -fb_addr equ $4000 -attr_addr equ $5800 -ula_port equ $fe +FB_ADDR equ $4000 +ATTR_ADDR equ $5800 +ULA_PORT equ $fe +START_ROW equ 3 + macro PRINTSTR, row, col, str + push bc + push de + ld b, \row + ld c, \col + call calc_cell_addr + ld hl, \str + call putstr + pop de + pop bc + endm + + macro PRINTVAL, row, col, str + push bc + push de + push hl + push af + ld b, \row + ld c, \col + call calc_cell_addr + ld hl, \str + call putstr + ld hl, \str + call strlen + add e + ld e, a + pop af + call putbin8 + pop hl + pop de + pop bc + endm + + main: call init - ld hl, fb_addr + 25 + ld hl, FB_ADDR + 25 call draw_logo - ld c, 4 - ld b, 12 - call calc_cell_addr - ld hl, str_foobar - call putstr + PRINTSTR START_ROW, 0, str_row0 + PRINTSTR START_ROW + 1, 0, str_row1 + PRINTSTR START_ROW + 2, 0, str_row2 + PRINTSTR START_ROW + 3, 0, str_row3 + PRINTSTR START_ROW + 4, 0, str_row4 + PRINTSTR START_ROW + 5, 0, str_row5 + PRINTSTR START_ROW + 6, 0, str_row6 + PRINTSTR START_ROW + 7, 0, str_row7 -.looptop: - jr .looptop +.mainloop: + ld bc, $fefe ; c: port $fe, b: row select $fe + xor a +.rowloop: + push af + push bc + add START_ROW + ld b, a + ld c, 17 + call calc_cell_addr + + pop bc + in a, (c) + call putbin5 + rlc b + pop af + inc a + cp $8 + jr nz, .rowloop + jr .mainloop init: ; setup attributes - ld hl, attr_addr + ld hl, ATTR_ADDR ld a, $47 ld b, 24 .attry: ld c, 32 @@ -33,7 +89,7 @@ init: jr nz, .attry ; clear screen - ld hl, fb_addr + ld hl, FB_ADDR xor a ld b, 192 .clry: ld c, 32 @@ -45,7 +101,7 @@ init: jr nz, .clry ; set border - out (ula_port), a + out (ULA_PORT), a ret @@ -75,7 +131,7 @@ calc_cell_addr: ld a, b ; grap Y one more time and $7 ; keep low 3 bits of Y in a or d ; combine with Y6-Y7 - ld bc, fb_addr + ld bc, FB_ADDR or b ; combine with high byte of fb address ld d, a ; move result back to d pop af @@ -83,6 +139,7 @@ calc_cell_addr: ; hl: dest draw_logo: + push hl ld de, logo ld b, 16 .logoy: ld c, 7 @@ -109,22 +166,45 @@ draw_logo: pop bc dec b jr nz, .logoy + pop hl + + ; attr + ld a, h + srl a + srl a + srl a + or $58 + ld h, a + ld a, $42 + + push hl + pop ix + ld b, 7 +.sattr: ld (ix), a + ld (ix + 32), a + inc ix + dec b + jr nz, .sattr ret ; de: dest ; a: char putchar: ; is it a digit? - ld bc, glyph_0 sub '0' ret c - cp 10 - jr c, .common + cp 11 + jr nc, .notdigit + push bc + ld bc, glyph_0 + jr .common +.notdigit: ; is it A-Z ? sub 'A'-'0' ret c - cp 27 + cp 30 ret nc + push bc ld bc, glyph_a .common: push de @@ -145,29 +225,79 @@ putchar: jr nz, .chartop pop hl pop de + pop bc ret ; de: dest ; hl: str putstr: - xor a + push de + push bc +.loop: xor a ld b, (hl) cp b jr z, .done ld a, b call putchar inc hl - inc de - jr putstr -.done: ret + inc e + jr .loop +.done: pop bc + pop de + ret ; de: dest ; a: number putbin8: + push de + push bc ld b, 8 +.loop: rlca + push af + and 1 + add '0' + call putchar + pop af + inc e + dec b + jr nz, .loop + pop bc + pop de + ret + +putbin5: + push de + push bc + ld b, 5 + rlca + rlca + rlca + jr putbin8.loop + ; hl: string + ; return -> a +strlen: + push hl + xor a + ld b, a +.loop: cp (hl) + jr z, .done + inc hl + inc b + jr .loop +.done: ld a, b + pop hl + ret -str_foobar asciiz 'FOOBAR 1234567890' + +str_row0 asciiz 'ROW0: V C X Z [: ' +str_row1 asciiz 'ROW1: G F D S A: ' +str_row2 asciiz 'ROW2: T R E W Q: ' +str_row3 asciiz 'ROW3: 5 4 3 2 1: ' +str_row4 asciiz 'ROW4: 6 7 8 9 0: ' +str_row5 asciiz 'ROW5: Y U I O P: ' +str_row6 asciiz 'ROW6: H J K L ^: ' +str_row7 asciiz 'ROW7: B N M ] \: ' include glyphs.inc include logo.inc -- 1.7.10.4