initial commit
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 9 Feb 2020 05:24:32 +0000 (07:24 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 9 Feb 2020 05:24:32 +0000 (07:24 +0200)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
glyphs.inc [new file with mode: 0644]
testrom.asm [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..7c5782d
--- /dev/null
@@ -0,0 +1,5 @@
+*.o
+*.bin
+*.rom
+*.tap
+*.swp
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..e0e5c42
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,41 @@
+name = testrom
+src = $(wildcard *.asm)
+obj = $(src:.asm=.o)
+bin = $(name).bin
+rom = $(name).rom
+tap = $(name).tap
+
+AS = vasmz80_oldstyle
+ASFLAGS = -Fvobj
+LD = vlink
+LDFLAGS = -b rawbin1
+
+.PHONY: tap
+tap: $(tap)
+
+.PHONY: rom
+rom: $(rom)
+
+$(bin): $(obj)
+       $(LD) -o $@ $(LDFLAGS) -Ttext 28000 $(obj)
+
+$(rom): $(obj)
+       $(LD) -o $@ $(LDFLAGS) -Ttext 0 $(obj)
+
+$(tap): $(bin)
+       appmake +zx -o $@ --org 28000 --blockname $(name) -b $<
+
+%.o: %.asm
+       $(AS) -o $@ $(ASFLAGS) $< >/dev/null
+
+.PHONY: clean
+clean:
+       rm -f $(bin) $(rom) $(tap) $(obj)
+
+.PHONY: run
+run: $(tap)
+       fuse-sdl $(tap)
+
+.PHONY: program
+program: $(rom)
+       minipro -p 'AT28C16 @DIP24' -s -w $<
diff --git a/glyphs.inc b/glyphs.inc
new file mode 100644 (file)
index 0000000..c0e4cd2
--- /dev/null
@@ -0,0 +1,235 @@
+; vi:filetype=z80:
+glyph_a:
+       db %00010000
+       db %00101000
+       db %00101000
+       db %01111100
+       db %01000100
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_b:
+       db %11111000
+       db %01000100
+       db %01000100
+       db %01111100
+       db %01000010
+       db %01000010
+       db %11111100
+       db %00000000
+glyph_c:
+       db %00111100
+       db %01000010
+       db %01000000
+       db %01000000
+       db %01000000
+       db %01000010
+       db %00111100
+       db %00000000
+glyph_d:
+       db %11111000
+       db %01000100
+       db %01000010
+       db %01000010
+       db %01000010
+       db %01000100
+       db %11111000
+       db %00000000
+glyph_e:
+       db %11111110
+       db %01000010
+       db %01001000
+       db %01111000
+       db %01001000
+       db %01000010
+       db %11111110
+       db %00000000
+glyph_f:
+       db %11111110
+       db %01000010
+       db %01001000
+       db %01111000
+       db %01001000
+       db %01000000
+       db %11100000
+       db %00000000
+glyph_g:
+       db %00111100
+       db %01000010
+       db %01000000
+       db %01001110
+       db %01000010
+       db %01000010
+       db %00111100
+       db %00000000
+glyph_h:
+       db %11101110
+       db %01000100
+       db %01000100
+       db %01111100
+       db %01000100
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_i:
+       db %00111000
+       db %00010000
+       db %00010000
+       db %00010000
+       db %00010000
+       db %00010000
+       db %00111000
+       db %00000000
+glyph_j:
+       db %00001110
+       db %00000100
+       db %00000100
+       db %01000100
+       db %01000100
+       db %01000100
+       db %00111000
+       db %00000000
+glyph_k:
+       db %11101100
+       db %01001000
+       db %01010000
+       db %01110000
+       db %01001000
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_l:
+       db %01110000
+       db %00100000
+       db %00100000
+       db %00100000
+       db %00100000
+       db %00100010
+       db %01111110
+       db %00000000
+glyph_m:
+       db %11000110
+       db %01101100
+       db %01101100
+       db %01010100
+       db %01010100
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_n:
+       db %11000110
+       db %01100100
+       db %01010100
+       db %01010100
+       db %01001100
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_o:
+       db %00111100
+       db %01000010
+       db %01000010
+       db %01000010
+       db %01000010
+       db %01000010
+       db %00111100
+       db %00000000
+glyph_p:
+       db %11111000
+       db %01000100
+       db %01000100
+       db %01111000
+       db %01000000
+       db %01000000
+       db %11100000
+       db %00000000
+glyph_q:
+       db %00111100
+       db %01000010
+       db %01000010
+       db %01000010
+       db %01001010
+       db %01000100
+       db %00111010
+       db %00000000
+glyph_r:
+       db %11111000
+       db %01000100
+       db %01000100
+       db %01111000
+       db %01001000
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_s:
+       db %00111100
+       db %01000010
+       db %01000000
+       db %00111100
+       db %00000010
+       db %01000010
+       db %01111100
+       db %00000000
+glyph_t:
+       db %11111110
+       db %10010010
+       db %00010000
+       db %00010000
+       db %00010000
+       db %00010000
+       db %00111000
+       db %00000000
+glyph_u:
+       db %11101110
+       db %01000100
+       db %01000100
+       db %01000100
+       db %01000100
+       db %01000100
+       db %00111000
+       db %00000000
+glyph_v:
+       db %11101110
+       db %01000100
+       db %01000100
+       db %01000100
+       db %00101000
+       db %00101000
+       db %00010000
+       db %00000000
+glyph_w:
+       db %11101110
+       db %01000100
+       db %01000100
+       db %01010100
+       db %01010100
+       db %00101000
+       db %00101000
+       db %00000000
+glyph_x:
+       db %11101110
+       db %01000100
+       db %00101000
+       db %00010000
+       db %00101000
+       db %01000100
+       db %11101110
+       db %00000000
+glyph_y:
+       db %11101110
+       db %01000100
+       db %00101000
+       db %00111000
+       db %00010000
+       db %00010000
+       db %00111000
+       db %00000000
+glyph_z:
+       db %11111110
+       db %10000100
+       db %00001000
+       db %00010000
+       db %00100000
+       db %01000010
+       db %11111110
+       db %00000000
diff --git a/testrom.asm b/testrom.asm
new file mode 100644 (file)
index 0000000..5d6ce67
--- /dev/null
@@ -0,0 +1,112 @@
+; vi:filetype=z80:
+fb_addr equ $4000
+attr_addr equ $5800
+ula_port equ $fe
+
+main:
+       call init
+       ld c, 16
+       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
+
+.looptop:
+       jr .looptop
+
+init:
+       ; setup attributes
+       ld hl, attr_addr
+       ld a, $47
+       ld b, 24
+.attry:        ld c, 32
+.attrx:        ld (hl), a
+       inc hl
+       dec c
+       jr nz, .attrx
+       dec b
+       jr nz, .attry
+
+       ; clear screen
+       ld hl, fb_addr
+       xor a
+       ld b, 192
+.clry: ld c, 32
+.clrx: ld (hl), a
+       inc hl
+       dec c
+       jr nz, .clrx
+       dec b
+       jr nz, .clry
+
+       ; set border
+       out (ula_port), a
+       
+       ret
+
+; expects X -> c, Y -> b, returns in de
+calc_cell_addr:
+       push af
+       sla b
+       sla b           ; change from blocks to pixels
+       sla b
+       ; construct low address byte -> e
+       ld a, b         ; start with Y
+       sla a
+       sla a
+       and $e0         ; keep top 3 bits
+       ld e, a         ; move into e
+       ld a, c         ; a <- X
+       and $1f         ; keep low 5 bits
+       or e            ; combine with Y bits
+       ld e, a         ; move the result back to e
+       ; construct high address byte -> d
+       ld a, b         ; start with Y again
+       sra a
+       sra a
+       sra a
+       and $18         ; keep bits 3 and 4
+       ld d, a         ; keep it in d
+       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
+       or b            ; combine with high byte of fb address
+       ld d, a         ; move result back to d
+       pop af
+       ret
+
+
+       ; de: dest
+       ; a: char
+putchar:
+       sub 'A'
+       ret c
+       cp 27
+       ret nc
+       push de
+       sla a
+       sla a
+       sla a
+       ld h, 0
+       ld l, a
+       ld bc, glyph_a
+       add hl, bc
+       ld c, 8
+.chartop:
+       ld a, (hl)
+       ld (de), a
+       inc d
+       inc hl
+       dec c
+       jr nz, .chartop
+       pop de
+       ret
+
+       include glyphs.inc