hgr_font: more or less working now

This commit is contained in:
Vince Weaver 2021-08-09 21:46:19 -04:00
parent 38b8751c21
commit c61a85b33f
12 changed files with 2508 additions and 6 deletions

View File

@ -1,26 +1,174 @@
.include "hardware.inc"
TEMP0 = $10
TEMP1 = $11
TEMP2 = $12
TEMP3 = $13
TEMP4 = $14
TEMP5 = $15
HGR_BITS = $1C
GBASL = $26
GBASH = $27
CURSOR_X = $62
CURSOR_Y = $63
HGR_COLOR = $E4
P0 = $F1
P1 = $F2
P2 = $F3
P3 = $F4
P4 = $F5
P5 = $F6
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
COUNT = TEMP5
font_test:
jsr vgi_make_tables
jsr HGR
VGI_RCOLOR = P0
VGI_RX1 = P1
VGI_RY1 = P2
VGI_RXRUN = P3
VGI_RYRUN = P4
VGI_RCOLOR2 = P5 ; only for dither
; draw rectangle
lda #$33
sta VGI_RCOLOR
lda #53
sta VGI_RX1
lda #24
sta VGI_RY1
lda #200
sta VGI_RXRUN
lda #58
sta VGI_RYRUN
jsr vgi_simple_rectangle
; draw lines
ldx #2 ; purple
lda COLORTBL,X
sta HGR_COLOR
ldy #0
ldx #59
lda #29
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #59
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldy #0
ldx #247
lda #29
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #247
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldy #0
ldx #57
lda #29
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #249
ldy #29
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #249
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #57
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #57
ldy #29
jsr HGLIN ; line to (X,A),(Y)
ldy #0
ldx #58
lda #30
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #248
ldy #30
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #248
ldy #77
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #58
ldy #77
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #58
ldy #30
jsr HGLIN ; line to (X,A),(Y)
; ldx #5
; ldy #10
; lda #'A'
; jsr hgr_put_char
lda #<test3
sta OUTL
lda #>test3
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
lda #<test1
sta OUTL
lda #>test1
@ -45,7 +193,14 @@ test1:
.byte 0,10,"PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS!",0
test2:
.byte 0,30,"pack my box with five dozen liquor jugs@",0
.byte 0,150,"pack my box with five dozen liquor jugs?",0
test3:
.byte 9,36,"This is a HGR font test.",0
test4: .byte 0,120,"0123456789)(*&^%$#@!`~<>,./';:[]{}\|_+=",127,0
test5: .byte 0,130,"@/\/\/\/\______ |",0
.include "hgr_font.s"
.include "hgr_rectangle.s"

View File

@ -30,7 +30,7 @@ hgr_put_string_loop:
jmp hgr_put_string_loop
hgr_put_string_done:
rts
; rts ; inc once more
@ -125,7 +125,7 @@ hgr_font:
.byte $14 ; 01010 X001 0100
.byte $3e ; 11111 X011 1110
.byte $14 ; 01010 X001 0100
.byte $3d ; 11111 X011 1110
.byte $3e ; 11111 X011 1110
.byte $14 ; 01010 X001 0100
.byte $14 ; 01010 X001 0100
.byte $00
@ -322,7 +322,7 @@ hgr_font:
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1e ; 01111 X001 1110
.byte $3c ; 01111 X011 1100
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $0e ; 11100 X000 1110
@ -348,7 +348,7 @@ hgr_font:
; < $3C
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $08 ; 01000 X000 0100
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $04 ; 01000 X000 0100
.byte $08 ; 00100 X000 1000
@ -960,6 +960,6 @@ hgr_font:
.byte $14 ; 0010100 001 0100
.byte $2a ; 0101010 010 1010
.byte $14 ; 0010100 001 0100
.byte $00 ; 0000000 000 0000
.byte $2a ; 0101010 010 1010
.byte $00 ; 0000000 000 0000
.byte $00

View File

@ -0,0 +1,308 @@
; HGR Rectangle
; VGI Rectangle test
COLOR_MODE = TEMP0
OTHER_MASK = TEMP1
XRUN = TEMP2
div7_table = $B000
mod7_table = $B100
; FAST
;=================================
; Simple Rectangle
;=================================
; VGI_RCOLOR = P0
; VGI_RX1 = P1
; VGI_RY1 = P2
; VGI_RXRUN = P3
; VGI_RYRUN = P4
; VGI_RCOLOR2 = P5 ; only for dither
;==================================
; VGI Simple Rectangle
;==================================
vgi_simple_rectangle:
lda #0
sta COLOR_MODE
simple_rectangle_loop:
lda COLOR_MODE
beq simple_colors
bmi striped_colors
bpl handle_dither
simple_colors:
lda VGI_RCOLOR
asl ; nibble swap by david galloway
adc #$80
rol
asl
adc #$80
rol
sta VGI_RCOLOR
and #$f
tax
lda COLORTBL,X
sta HGR_COLOR
jmp done_colors
handle_dither:
lda COUNT
and #$1
beq deven_color
dodd_color:
lda VGI_RCOLOR
jmp dsave_color
deven_color:
lda VGI_RCOLOR2
dsave_color:
sta HGR_COLOR
inc COUNT
jmp done_colors
striped_colors:
; don't need to do anything here?
done_colors:
; get ROW into (GBASL)
ldx VGI_RX1 ; X1 into X
lda VGI_RY1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
; Y is already the RX1/7
; adjust color if in striped mode
lda COLOR_MODE
bpl not_striped
jsr swap_colors
not_striped:
; copy the XRUN
lda VGI_RXRUN
sta XRUN
inc XRUN ; needed because we compare with beq/bne
; check if narrow corner case where begin and end same block
; if RX%7 + XRUN < 8
ldx VGI_RX1
lda mod7_table,X
clc
adc XRUN
cmp #8
bcs not_corner
corner:
; want to use MASK of left_mask, MOD7 and 7-XRUN
lda mod7_table,X
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
ldx XRUN
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
jmp done_row ; that's all
not_corner:
; see if not starting on boundary
ldx VGI_RX1
lda mod7_table,X
beq draw_run
; handle not full left border
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
eor (GBASL),Y
sta (GBASL),Y
iny ; move to next
; adjust RUN length by 7- mod7
txa ; load mod7
eor #$ff
sec
adc #7
eor #$ff
sec
adc XRUN
sta XRUN
; lda HGR_BITS ; cycle colors for next
; jsr COLOR_SHIFT
jsr swap_colors
;no_shift:
; draw common
draw_run:
lda XRUN
cmp #7
bcc draw_right ; blt
lda HGR_BITS ; get color
sta (GBASL),Y ; store out
; jsr COLOR_SHIFT ; shift colors
iny ; move to next block
jsr swap_colors
lda XRUN ; take 7 off the run
sec
sbc #7
sta XRUN
jmp draw_run
; draw rightmost
draw_right:
beq done_row
; lda HGR_BITS
; jsr COLOR_SHIFT
; see if not starting on boundary
ldx XRUN
tax
lda (GBASL),Y
eor HGR_BITS
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
done_row:
inc VGI_RY1
dec VGI_RYRUN
;bne simple_rectangle_loop
beq done_done
jmp simple_rectangle_loop
done_done:
rts
;==========================
; swap colors
;==========================
swap_colors:
lda COLOR_MODE
bmi swap_colors_striped
lda HGR_BITS ; get color
jsr COLOR_SHIFT ; shift colors
rts
swap_colors_striped:
tya
and #1
bne swap_odd
lda VGI_RCOLOR
jmp swap_done
swap_odd:
lda VGI_RCOLOR2
swap_done:
sta HGR_BITS
rts
;=====================
; make /7 %7 tables
;=====================
vgi_init:
vgi_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
rts
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF

View File

@ -0,0 +1,34 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
DOS33_RAW = ../../../utils/dos33fs-utils/dos33_raw
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKER_SCRIPTS = ../../../linker_scripts
EMPTY_DISK = ../../../empty_disk
all: hgr_font.dsk
hgr_font.dsk: HELLO FONT_TEST
cp $(EMPTY_DISK)/empty.dsk hgr_font.dsk
$(DOS33) -y hgr_font.dsk SAVE A HELLO
$(DOS33) -y hgr_font.dsk BSAVE -a 0x6000 FONT_TEST
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
FONT_TEST: font_test.o
ld65 -o FONT_TEST font_test.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
font_test.o: font_test.s hgr_font.s hgr_1x8_sprite.s
ca65 -o font_test.o font_test.s -l font_test.lst
###
clean:
rm -f *~ *.o *.lst HELLO FONT_TEST

View File

@ -0,0 +1,370 @@
; note -- modified by Vince Weaver to assemble with ca65
; in this case, A = page to decompress to
; getsrc_smc+1, getsrc_smc+2 is src location
; -----------------------------------------------------------------------------
; Decompress raw LZSA2 block.
; Create one with lzsa -r -f2 <original_file> <compressed_file>
;
; in:
; * LZSA_SRC_LO and LZSA_SRC_HI contain the compressed raw block address
; * LZSA_DST_LO and LZSA_DST_HI contain the destination buffer address
;
; out:
; * LZSA_DST_LO and LZSA_DST_HI contain the last decompressed byte address, +1
;
; -----------------------------------------------------------------------------
; Backward decompression is also supported, use lzsa -r -b -f2 <original_file> <compressed_file>
; To use it, also define BACKWARD_DECOMPRESS=1 before including this code!
;
; in:
; * LZSA_SRC_LO/LZSA_SRC_HI must contain the address of the last byte of compressed data
; * LZSA_DST_LO/LZSA_DST_HI must contain the address of the last byte of the destination buffer
;
; out:
; * LZSA_DST_LO/LZSA_DST_HI contain the last decompressed byte address, -1
;
; -----------------------------------------------------------------------------
;
; Copyright (C) 2019 Emmanuel Marty, Peter Ferrie
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any damages
; arising from the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation would be
; appreciated but is not required.
; 2. Altered source versions must be plainly marked as such, and must not be
; misrepresented as being the original software.
; 3. This notice may not be removed or altered from any source distribution.
; -----------------------------------------------------------------------------
;NIBCOUNT = $FC ; zero-page location for temp offset
decompress_lzsa2_fast:
sta LZSA_DST_HI
ldy #$00
sty LZSA_DST_LO
sty NIBCOUNT
decode_token:
jsr getsrc ; read token byte: XYZ|LL|MMM
pha ; preserve token on stack
and #$18 ; isolate literals count (LL)
beq no_literals ; skip if no literals to copy
cmp #$18 ; LITERALS_RUN_LEN_V2?
bcc prepare_copy_literals ; if less, count is directly embedded in token
jsr getnibble ; get extra literals length nibble
; add nibble to len from token
adc #$02 ; (LITERALS_RUN_LEN_V2) minus carry
cmp #$12 ; LITERALS_RUN_LEN_V2 + 15 ?
bcc prepare_copy_literals_direct ; if less, literals count is complete
jsr getsrc ; get extra byte of variable literals count
; the carry is always set by the CMP above
; GETSRC doesn't change it
sbc #$EE ; overflow?
jmp prepare_copy_literals_direct
prepare_copy_literals_large:
; handle 16 bits literals count
; literals count = directly these 16 bits
jsr getlargesrc ; grab low 8 bits in X, high 8 bits in A
tay ; put high 8 bits in Y
bcs prepare_copy_literals_high ; (*same as JMP PREPARE_COPY_LITERALS_HIGH but shorter)
prepare_copy_literals:
lsr ; shift literals count into place
lsr
lsr
prepare_copy_literals_direct:
tax
bcs prepare_copy_literals_large ; if so, literals count is large
prepare_copy_literals_high:
txa
beq copy_literals
iny
copy_literals:
jsr getput ; copy one byte of literals
dex
bne copy_literals
dey
bne copy_literals
no_literals:
pla ; retrieve token from stack
pha ; preserve token again
asl
bcs repmatch_or_large_offset ; 1YZ: rep-match or 13/16 bit offset
asl ; 0YZ: 5 or 9 bit offset
bcs offset_9_bit
; 00Z: 5 bit offset
ldx #$FF ; set offset bits 15-8 to 1
jsr getcombinedbits ; rotate Z bit into bit 0, read nibble for bits 4-1
ora #$E0 ; set bits 7-5 to 1
bne got_offset_lo ; go store low byte of match offset and prepare match
offset_9_bit: ; 01Z: 9 bit offset
;;asl ; shift Z (offset bit 8) in place
rol
rol
and #$01
eor #$FF ; set offset bits 15-9 to 1
bne got_offset_hi ; go store high byte, read low byte of match offset and prepare match
; (*same as JMP GOT_OFFSET_HI but shorter)
repmatch_or_large_offset:
asl ; 13 bit offset?
bcs repmatch_or_16bit ; handle rep-match or 16-bit offset if not
; 10Z: 13 bit offset
jsr getcombinedbits ; rotate Z bit into bit 8, read nibble for bits 12-9
adc #$DE ; set bits 15-13 to 1 and substract 2 (to substract 512)
bne got_offset_hi ; go store high byte, read low byte of match offset and prepare match
; (*same as JMP GOT_OFFSET_HI but shorter)
repmatch_or_16bit: ; rep-match or 16 bit offset
;;ASL ; XYZ=111?
bmi rep_match ; reuse previous offset if so (rep-match)
; 110: handle 16 bit offset
jsr getsrc ; grab high 8 bits
got_offset_hi:
tax
jsr getsrc ; grab low 8 bits
got_offset_lo:
sta OFFSLO ; store low byte of match offset
stx OFFSHI ; store high byte of match offset
rep_match:
.ifdef BACKWARD_DECOMPRESS
; Backward decompression - substract match offset
sec ; add dest + match offset
lda putdst+1 ; low 8 bits
OFFSLO = *+1
sbc #$AA
sta copy_match_loop+1 ; store back reference address
lda putdst+2
OFFSHI = *+1
sbc #$AA ; high 8 bits
sta copy_match_loop+2 ; store high 8 bits of address
sec
.else
; Forward decompression - add match offset
clc ; add dest + match offset
lda putdst+1 ; low 8 bits
OFFSLO = *+1
adc #$AA
sta copy_match_loop+1 ; store back reference address
OFFSHI = *+1
lda #$AA ; high 8 bits
adc putdst+2
sta copy_match_loop+2 ; store high 8 bits of address
.endif
pla ; retrieve token from stack again
and #$07 ; isolate match len (MMM)
adc #$01 ; add MIN_MATCH_SIZE_V2 and carry
cmp #$09 ; MIN_MATCH_SIZE_V2 + MATCH_RUN_LEN_V2?
bcc prepare_copy_match ; if less, length is directly embedded in token
jsr getnibble ; get extra match length nibble
; add nibble to len from token
adc #$08 ; (MIN_MATCH_SIZE_V2 + MATCH_RUN_LEN_V2) minus carry
cmp #$18 ; MIN_MATCH_SIZE_V2 + MATCH_RUN_LEN_V2 + 15?
bcc prepare_copy_match ; if less, match length is complete
jsr getsrc ; get extra byte of variable match length
; the carry is always set by the CMP above
; GETSRC doesn't change it
sbc #$E8 ; overflow?
prepare_copy_match:
tax
bcc prepare_copy_match_y ; if not, the match length is complete
beq decompression_done ; if EOD code, bail
; Handle 16 bits match length
jsr getlargesrc ; grab low 8 bits in X, high 8 bits in A
tay ; put high 8 bits in Y
prepare_copy_match_y:
txa
beq copy_match_loop
iny
copy_match_loop:
lda $AAAA ; get one byte of backreference
jsr putdst ; copy to destination
.ifdef BACKWARD_DECOMPRESS
; Backward decompression -- put backreference bytes backward
lda copy_match_loop+1
beq getmatch_adj_hi
getmatch_done:
dec copy_match_loop+1
.else
; Forward decompression -- put backreference bytes forward
inc copy_match_loop+1
beq getmatch_adj_hi
getmatch_done:
.endif
dex
bne copy_match_loop
dey
bne copy_match_loop
jmp decode_token
.ifdef BACKWARD_DECOMPRESS
getmatch_adj_hi:
dec copy_match_loop+2
jmp getmatch_done
.else
getmatch_adj_hi:
inc copy_match_loop+2
jmp getmatch_done
.endif
getcombinedbits:
eor #$80
asl
php
jsr getnibble ; get nibble into bits 0-3 (for offset bits 1-4)
plp ; merge Z bit as the carry bit (for offset bit 0)
combinedbitz:
rol ; nibble -> bits 1-4; carry(!Z bit) -> bit 0 ; carry cleared
decompression_done:
rts
getnibble:
NIBBLES = *+1
lda #$AA
lsr NIBCOUNT
bcc need_nibbles
and #$0F ; isolate low 4 bits of nibble
rts
need_nibbles:
inc NIBCOUNT
jsr getsrc ; get 2 nibbles
sta NIBBLES
lsr
lsr
lsr
lsr
sec
rts
.ifdef BACKWARD_DECOMPRESS
; Backward decompression -- get and put bytes backward
getput:
jsr getsrc
putdst:
LZSA_DST_LO = *+1
LZSA_DST_HI = *+2
sta $AAAA
lda putdst+1
beq putdst_adj_hi
dec putdst+1
rts
putdst_adj_hi:
dec putdst+2
dec putdst+1
rts
getlargesrc:
jsr getsrc ; grab low 8 bits
tax ; move to X
; fall through grab high 8 bits
getsrc:
LZSA_SRC_LO = *+1
LZSA_SRC_HI = *+2
lda $AAAA
pha
lda getsrc+1
beq getsrc_adj_hi
dec getsrc+1
pla
rts
getsrc_adj_hi:
dec getsrc+2
dec getsrc+1
pla
rts
.else
; Forward decompression -- get and put bytes forward
getput:
jsr getsrc
putdst:
LZSA_DST_LO = *+1
LZSA_DST_HI = *+2
sta $AAAA
inc putdst+1
beq putdst_adj_hi
rts
putdst_adj_hi:
inc putdst+2
rts
getlargesrc:
jsr getsrc ; grab low 8 bits
tax ; move to X
; fall through grab high 8 bits
getsrc:
getsrc_smc:
LZSA_SRC_LO = *+1
LZSA_SRC_HI = *+2
lda $AAAA
inc getsrc+1
beq getsrc_adj_hi
rts
getsrc_adj_hi:
inc getsrc+2
rts
.endif

View File

@ -0,0 +1,206 @@
.include "hardware.inc"
TEMP0 = $10
TEMP1 = $11
TEMP2 = $12
TEMP3 = $13
TEMP4 = $14
TEMP5 = $15
HGR_BITS = $1C
GBASL = $26
GBASH = $27
CURSOR_X = $62
CURSOR_Y = $63
HGR_COLOR = $E4
P0 = $F1
P1 = $F2
P2 = $F3
P3 = $F4
P4 = $F5
P5 = $F6
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
COUNT = TEMP5
font_test:
jsr vgi_make_tables
jsr HGR
VGI_RCOLOR = P0
VGI_RX1 = P1
VGI_RY1 = P2
VGI_RXRUN = P3
VGI_RYRUN = P4
VGI_RCOLOR2 = P5 ; only for dither
; draw rectangle
lda #$33
sta VGI_RCOLOR
lda #53
sta VGI_RX1
lda #24
sta VGI_RY1
lda #200
sta VGI_RXRUN
lda #58
sta VGI_RYRUN
jsr vgi_simple_rectangle
; draw lines
ldx #2 ; purple
lda COLORTBL,X
sta HGR_COLOR
ldy #0
ldx #59
lda #29
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #59
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldy #0
ldx #247
lda #29
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #247
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldy #0
ldx #57
lda #29
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #249
ldy #29
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #249
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #57
ldy #78
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #57
ldy #29
jsr HGLIN ; line to (X,A),(Y)
ldy #0
ldx #58
lda #30
jsr HPLOT0 ; plot at (Y,X), (A)
ldx #0
lda #248
ldy #30
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #248
ldy #77
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #58
ldy #77
jsr HGLIN ; line to (X,A),(Y)
ldx #0
lda #58
ldy #30
jsr HGLIN ; line to (X,A),(Y)
; ldx #5
; ldy #10
; lda #'A'
; jsr hgr_put_char
lda #<test3
sta OUTL
lda #>test3
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
lda #<test1
sta OUTL
lda #>test1
sta OUTH
jsr hgr_put_string
lda #<test2
sta OUTL
lda #>test2
sta OUTH
jsr hgr_put_string
end:
jmp end
test1:
; 0123456789012345678901234567890123456789
.byte 0,10,"PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS!",0
test2:
.byte 0,150,"pack my box with five dozen liquor jugs?",0
test3:
.byte 9,36,"This is a HGR font test.",0
test4: .byte 0,120,"0123456789)(*&^%$#@!`~<>,./';:[]{}\|_+=",127,0
test5: .byte 0,130,"@/\/\/\/\______ |",0
.include "hgr_font.s"
.include "hgr_rectangle.s"

View File

@ -0,0 +1,102 @@
; HARDWARE LOCATIONS
KEYPRESS = $C000
KEYRESET = $C010
; SOFT SWITCHES
CLR80COL = $C000 ; PAGE0/PAGE1 normal
SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
EIGHTYCOLOFF = $C00C
EIGHTYCOLON = $C00D
TBCOLOR = $C022 ; IIgs text foreground / background colors
NEWVIDEO = $C029 ; IIgs graphics modes
SPEAKER = $C030
CLOCKCTL = $C034 ; bits 0-3 are IIgs border color
SET_GR = $C050
SET_TEXT = $C051
FULLGR = $C052
TEXTGR = $C053
PAGE0 = $C054
PAGE1 = $C055
LORES = $C056 ; Enable LORES graphics
HIRES = $C057 ; Enable HIRES graphics
AN3 = $C05E ; Annunciator 3
PADDLE_BUTTON0 = $C061
PADDL0 = $C064
PTRIG = $C070
; APPLESOFT BASIC ROUTINES
NORMAL = $F273
HGR2 = $F3D8
HGR = $F3E2
BKGND0 = $F3F4 ; clear current page to A
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
HPLOT0 = $F457 ; plot at (Y,X), (A)
COLOR_SHIFT = $F47E
HLINRL = $F530 ; (X,A),(Y)
HGLIN = $F53A ; line to (X,A),(Y)
COLORTBL = $F6F6
; MONITOR ROUTINES
HLINE = $F819 ; HLINE Y,$2C at A
VLINE = $F828 ; VLINE A,$2D at Y
CLRSCR = $F832 ; Clear low-res screen
CLRTOP = $F836 ; clear only top of low-res screen
SETCOL = $F864 ; COLOR=A
ROM_TEXT2COPY = $F962 ; iigs
TEXT = $FB36
TABV = $FB5B ; VTAB to A
ROM_MACHINEID = $FBB3 ; iigs
BELL = $FBDD ; ring the bell
BASCALC = $FBC1 ;
VTAB = $FC22 ; VTAB to CV
HOME = $FC58 ; Clear the text screen
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
CROUT1 = $FD8B
SETINV = $FE80 ; INVERSE
SETNORM = $FE84 ; NORMAL
COUT = $FDED ; output A to screen
COUT1 = $FDF0 ; output A to screen
COLOR_BLACK = 0
COLOR_RED = 1
COLOR_DARKBLUE = 2
COLOR_PURPLE = 3
COLOR_DARKGREEN = 4
COLOR_GREY = 5
COLOR_MEDIUMBLUE = 6
COLOR_LIGHTBLUE = 7
COLOR_BROWN = 8
COLOR_ORANGE = 9
COLOR_GREY2 = 10
COLOR_PINK = 11
COLOR_LIGHTGREEN = 12
COLOR_YELLOW = 13
COLOR_AQUA = 14
COLOR_WHITE = 15
COLOR_BOTH_BLACK = $00
COLOR_BOTH_RED = $11
COLOR_BOTH_DARKBLUE = $22
COLOR_BOTH_DARKGREEN = $44
COLOR_BOTH_GREY = $55
COLOR_BOTH_MEDIUMBLUE = $66
COLOR_BOTH_LIGHTBLUE = $77
COLOR_BOTH_BROWN = $88
COLOR_BOTH_ORANGE = $99
COLOR_BOTH_PINK = $BB
COLOR_BOTH_LIGHTGREEN = $CC
COLOR_BOTH_YELLOW = $DD
COLOR_BOTH_AQUA = $EE
COLOR_BOTH_WHITE = $FF

View File

@ -0,0 +1,4 @@
5 HOME
10 PRINT CHR$(4)"CATALOG"
20 REM PRINT CHR$(4)"BRUN PEASANT"

View File

@ -0,0 +1,45 @@
;======================
; hgr 1x8 draw sprite
;======================
; SPRITE in INL/INH
; Location at CURSOR_X CURSOR_Y*7
; X, Y, A trashed
hgr_draw_sprite_1x8:
; set up pointers
lda INL
sta hds_smc1+1
lda INH
sta hds_smc1+2
ldx #0
hgr_1x8_sprite_yloop:
txa
pha
clc
adc CURSOR_Y
ldx #0
ldy #0
; calc GBASL/GBASH
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
pla
tax
ldy CURSOR_X
lda (GBASL),Y
hds_smc1:
eor $D000,X ; not $0000 or it will make it ZP
sta (GBASL),Y
inx
cpx #8
bne hgr_1x8_sprite_yloop
rts

View File

@ -0,0 +1,965 @@
; Apple II font based on the one in ROM that sadly we can't access
; For II/II+ was uppercase only 5x7 using 2513 character generator
; For IIe moved to 5x8 though the descenders on lowercase can touch next line
; This is fixed-width can only put the fonts easily in a 40x24 grid
;===================
; in OUTL/OUTH
; first byte X, next byte Y, then string (NUL terminated)
hgr_put_string:
ldy #0
lda (OUTL),Y
sta CURSOR_X
jsr inc_outl
lda (OUTL),Y
sta CURSOR_Y
jsr inc_outl
hgr_put_string_loop:
ldy #0
lda (OUTL),Y
beq hgr_put_string_done
jsr hgr_put_char_cursor
inc CURSOR_X
jsr inc_outl
jmp hgr_put_string_loop
hgr_put_string_done:
; rts ; inc once more
inc_outl:
inc OUTL
bne outl_no_oflo
inc OUTH
outl_no_oflo:
rts
;==================
; in X
; Y in Y
; Char in A
hgr_put_char:
stx CURSOR_X
sty CURSOR_Y
hgr_put_char_cursor:
and #$7f ; strip high bit
sec
sbc #$20
bpl char_positive
; control char, just print space
lda #$0
char_positive:
ldx #$0
stx put_char_smc1+1
clc
rol
rol put_char_smc1+1
rol
rol put_char_smc1+1
rol
rol put_char_smc1+1
clc
adc #<(hgr_font)
sta INL
lda #>(hgr_font)
put_char_smc1:
adc #$d0
sta INH
jsr hgr_draw_sprite_1x8
rts
.include "hgr_1x8_sprite.s"
; we skip control chars before $20
hgr_font:
; ' ' $20
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
; ! $21
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $00
; " $22
.byte $14 ; 01010 X001 0100
.byte $14 ; 01010 X001 0100
.byte $14 ; 01010 X001 0100
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00
; # $23
.byte $14 ; 01010 X001 0100
.byte $14 ; 01010 X001 0100
.byte $3e ; 11111 X011 1110
.byte $14 ; 01010 X001 0100
.byte $3e ; 11111 X011 1110
.byte $14 ; 01010 X001 0100
.byte $14 ; 01010 X001 0100
.byte $00
; $ $24
.byte $08 ; 00100 X000 1000
.byte $3c ; 01111 X011 1100
.byte $0a ; 10100 X000 1010
.byte $1c ; 01110 X001 1100
.byte $28 ; 00101 X010 1000
.byte $1e ; 11110 X001 1110
.byte $08 ; 00100 X000 1000
.byte $00
; % $25
.byte $06 ; 11000 X000 0110
.byte $26 ; 11001 X010 0110
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $32 ; 10011 X011 0010
.byte $30 ; 00011 X011 0000
.byte $00
; & $26
.byte $04 ; 01000 X000 0100
.byte $0a ; 10100 X000 1010
.byte $0a ; 10100 X000 1010
.byte $04 ; 01000 X000 0100
.byte $2a ; 10101 X010 1010
.byte $12 ; 10010 X001 0010
.byte $2c ; 01101 X010 1100
.byte $00
; ' $27
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00
; ( $28
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $04 ; 01000 X000 0100
.byte $08 ; 00100 X000 1000
.byte $00
; ) $29
.byte $08 ; 00100 X000 1000
.byte $10 ; 00010 X001 0000
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $00
; * $2A
.byte $08 ; 00100 X000 1000
.byte $2a ; 10101 X010 1010
.byte $1c ; 01110 X001 1100
.byte $08 ; 00100 X000 1000
.byte $1c ; 01110 X001 1100
.byte $2a ; 10101 X010 1010
.byte $08 ; 00100 X000 1000
.byte $00
; + $2B
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $3e ; 11111 X011 1110
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $00
; , $2C
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $00
; - $2D
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $3e ; 11111 X011 1110
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 01000 X000 0000
.byte $00
; . $2E
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $00
; / $2F
.byte $00 ; 00000 X000 0000
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $00 ; 00000 X000 0000
.byte $00
; 0 $30
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $32 ; 10011 X011 0010
.byte $2a ; 10101 X010 1010
.byte $26 ; 11001 X010 0110
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; 1 $31
.byte $08 ; 00100 X000 1000
.byte $0c ; 01100 X000 1100
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $1c ; 01110 X001 1100
.byte $00
; 2 $32
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $20 ; 00001 X010 0000
.byte $18 ; 00110 X001 1000
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $3e ; 11111 X011 1110
.byte $00
; 3 $33
.byte $3e ; 11111 X011 1110
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $18 ; 00110 X001 1000
.byte $20 ; 00001 X010 0000
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; 4 $34
.byte $10 ; 00010 X001 0000
.byte $18 ; 00110 X001 1000
.byte $14 ; 01010 X001 0100
.byte $12 ; 10010 X001 0010
.byte $3e ; 11111 X011 1110
.byte $10 ; 00010 X001 0000
.byte $10 ; 00010 X001 0000
.byte $00
; 5 $35
.byte $3e ; 11111 X011 1110
.byte $02 ; 10000 X000 0010
.byte $1e ; 11110 X001 1110
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; 6 $36
.byte $38 ; 00111 X011 1000
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $1e ; 11110 X001 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; 7 $37
.byte $3e ; 11111 X011 1110
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $04 ; 01000 X000 0100
.byte $04 ; 01000 X000 0100
.byte $00
; 8 $38
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; 9 $39
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $3c ; 01111 X011 1100
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $0e ; 11100 X000 1110
.byte $00
; : $3A
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00
; ; $3B
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $00
; < $3C
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $04 ; 01000 X000 0100
.byte $08 ; 00100 X000 1000
.byte $10 ; 00010 X001 0000
.byte $00
; = $3D
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $3e ; 11111 X011 1110
.byte $00 ; 00000 X000 0000
.byte $3e ; 11111 X011 1110
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00
; > $3E
.byte $04 ; 01000 X000 0100
.byte $08 ; 00100 X000 1000
.byte $10 ; 00010 X001 0000
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $00
; ? $3F
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $00
; @ $40
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $2a ; 10101 X010 1010
.byte $3a ; 10111 X011 1010
.byte $1a ; 10110 X001 1010
.byte $02 ; 10000 X000 0010
.byte $3c ; 01111 X011 1100
.byte $00
; A $41
.byte $08 ; 00100 X000 1000
.byte $14 ; 01010 X001 0100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $3E ; 11111 X011 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $00
; B $42
.byte $1E ; 11110 X001 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1E ; 11110 X001 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1E ; 11110 X001 1110
.byte $00
; C $43
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; D $44
.byte $1e ; 11110 X001 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1e ; 11110 X001 1110
.byte $00
; E $45
.byte $3E ; 11111 X011 1110
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $1e ; 11110 X001 1110
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $3E ; 11111 X011 1110
.byte $00
; F $46
.byte $3E ; 11111 X011 1110
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $1E ; 11110 X001 1110
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $00
; G $47
.byte $3c ; 01111 X011 1100
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $32 ; 10011 X011 0010
.byte $22 ; 10001 X010 0010
.byte $3c ; 01111 X011 1100
.byte $00
; H $48
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $3E ; 11111 X011 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $00
; I $49
.byte $1c ; 01110 X001 1100
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $1c ; 01110 X001 1100
.byte $00
; J $4A
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $20 ; 00001 X010 0000
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; K $4B
.byte $22 ; 10001 X010 0010
.byte $12 ; 10010 X001 0010
.byte $1A ; 10100 X000 1010
.byte $06 ; 11000 X000 0110
.byte $0A ; 10100 X000 1010
.byte $12 ; 10010 X001 0010
.byte $22 ; 10001 X010 0010
.byte $00
; L $4C
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $3E ; 11111 X011 1110
.byte $00
; M $4D
.byte $22 ; 10001 X010 0010
.byte $36 ; 11011 X011 0110
.byte $2a ; 10101 X010 1010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $00
; N $4E
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $26 ; 11001 X010 0110
.byte $2a ; 10101 X010 1010
.byte $32 ; 10011 X011 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $00
; O $4F
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; P $50
.byte $1e ; 11110 X001 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1e ; 11110 X001 1110
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $02 ; 10000 X000 0010
.byte $00
; Q $51
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $2a ; 10101 X010 1010
.byte $12 ; 10010 X001 0010
.byte $2c ; 01101 X010 1100
.byte $00
; R $52
.byte $1e ; 11110 X001 1110
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1e ; 11110 X001 1110
.byte $0a ; 10100 X000 1010
.byte $12 ; 10010 X001 0010
.byte $22 ; 10001 X010 0010
.byte $00
; S $53
.byte $1c ; 01110 X001 1100
.byte $22 ; 10001 X010 0010
.byte $02 ; 10000 X000 0010
.byte $1c ; 01110 X001 1100
.byte $20 ; 00001 X010 0000
.byte $22 ; 10001 X010 0010
.byte $1c ; 01110 X001 1100
.byte $00
; T $54
.byte $3E ; 11111 X011 1110
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $00
; U $55
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $1C ; 01110 X001 1100
.byte $00
; V $56
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $14 ; 01010 X001 0100
.byte $08 ; 00100 X000 1000
.byte $00
; W $57
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $2A ; 10101 X010 1010
.byte $2A ; 10101 X010 1010
.byte $36 ; 11011 X011 0110
.byte $22 ; 10001 X010 0010
.byte $00
; X $58
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $14 ; 01010 X001 0100
.byte $08 ; 00100 X000 1000
.byte $14 ; 01010 X001 0100
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $00
; Y $59
.byte $22 ; 10001 X010 0010
.byte $22 ; 10001 X010 0010
.byte $14 ; 01010 X001 0100
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $08 ; 00100 X000 1000
.byte $00
; Z $5A
.byte $3e ; 11111 X011 1110
.byte $20 ; 00001 X010 0000
.byte $10 ; 00010 X001 0000
.byte $08 ; 00100 X000 1000
.byte $04 ; 01000 X000 0100
.byte $02 ; 10000 X000 0010
.byte $3e ; 11111 X011 1110
.byte $00
; [ $5B
.byte $3e ; 11111 X011 1110
.byte $06 ; 11000 X000 0110
.byte $06 ; 11000 X000 0110
.byte $06 ; 11000 X000 0110
.byte $06 ; 11000 X000 0110
.byte $06 ; 11000 X000 0110
.byte $3e ; 11111 X011 1110
.byte $00
; \ $5C
.byte $00 ; 00000 X000 0000
.byte $02 ; 10000 X000 0010
.byte $04 ; 01000 X000 0100
.byte $08 ; 00100 X000 1000
.byte $10 ; 00010 X001 0000
.byte $20 ; 00001 X010 0000
.byte $00 ; 00000 X000 0000
.byte $00
; ] $5d
.byte $3e ; 11111 X011 1110
.byte $30 ; 00011 X011 0000
.byte $30 ; 00011 X011 0000
.byte $30 ; 00011 X011 0000
.byte $30 ; 00011 X011 0000
.byte $30 ; 00011 X011 0000
.byte $3e ; 11111 X011 1110
.byte $00
; ^ $5e
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $08 ; 00100 X000 1000
.byte $14 ; 01010 X001 0100
.byte $22 ; 10001 X010 0010
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00
; _ $5f
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $00 ; 00000 X000 0000
.byte $7f ; 11111 X111 1111
;*******************
; Lowercase
;*******************
; ` $60
.byte $04 ; 0010000 000 0100
.byte $08 ; 0001000 000 1000
.byte $10 ; 0000100 001 0000
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00
; a $61
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $1c ; 0011100 001 1100
.byte $20 ; 0000010 010 0000
.byte $3c ; 0011110 011 1100
.byte $22 ; 0100010 010 0010
.byte $3c ; 0011110 011 1100
.byte $00
; b $62
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $1e ; 0111100 001 1110
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $1e ; 0111100 001 1110
.byte $00
; c $63
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $3c ; 0011110 011 1100
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $3c ; 0011110 011 1100
.byte $00
; d $64
.byte $20 ; 0000010 010 0000
.byte $20 ; 0000010 010 0000
.byte $3c ; 0011110 011 1100
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $3c ; 0011110 011 1100
.byte $00
; e $65
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $1c ; 0011100 001 1100
.byte $22 ; 0100010 010 0010
.byte $3e ; 0111110 011 1110
.byte $02 ; 0100000 000 0010
.byte $3c ; 0011110 011 1100
.byte $00
; f $66
.byte $18 ; 0001100 001 1000
.byte $24 ; 0010010 010 0100
.byte $04 ; 0010000 000 0100
.byte $1e ; 0111100 001 1110
.byte $04 ; 0010000 000 0100
.byte $04 ; 0010000 000 0100
.byte $04 ; 0010000 000 0100
.byte $00
; g $67
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $1c ; 0011100 001 1100
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $3c ; 0011110 011 1100
.byte $20 ; 0000010 010 0000
.byte $1c ; 0011100 001 1100
; h $68
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $1e ; 0111100 001 1110
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $00
; i $69
.byte $08 ; 0001000 000 1000
.byte $00 ; 0000000 000 0000
.byte $0c ; 0011000 000 1100
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $1c ; 0011100 001 1100
.byte $00
; j $6A
.byte $10 ; 0000100 001 0000
.byte $00 ; 0000000 000 0000
.byte $18 ; 0001100 001 1000
.byte $10 ; 0000100 001 0000
.byte $10 ; 0000100 001 0000
.byte $10 ; 0000100 001 0000
.byte $12 ; 0100100 001 0010
.byte $0c ; 0011000 000 1100
; k $6B
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $22 ; 0100010 010 0010
.byte $12 ; 0100100 001 0010
.byte $0e ; 0111000 000 1110
.byte $12 ; 0100100 001 0010
.byte $22 ; 0100010 010 0010
.byte $00
; l $6c
.byte $0c ; 0011000 000 1100
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $1c ; 0011100 001 1100
.byte $00
; m $6d
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $36 ; 0110110 011 0110
.byte $2a ; 0101010 010 1010
.byte $2a ; 0101010 010 1010
.byte $2a ; 0101010 010 1010
.byte $22 ; 0100010 010 0010
.byte $00
; n $6e
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $1e ; 0111100 001 1110
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $00
; o $6f
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $1c ; 0011100 001 1100
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $1c ; 0011100 001 1100
.byte $00
; p $70
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $1e ; 0111100 001 1110
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $1e ; 0111100 001 1110
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
; q $71
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $3c ; 0011110 011 1100
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $3c ; 0011110 011 1100
.byte $20 ; 0000010 010 0000
.byte $20 ; 0000010 010 0000
; r $72
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $3a ; 0101110 011 1010
.byte $06 ; 0110000 000 0110
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $02 ; 0100000 000 0010
.byte $00
; s $73
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $3c ; 0011110 011 1100
.byte $02 ; 0100000 000 0010
.byte $1c ; 0011100 001 1100
.byte $20 ; 0000010 010 0000
.byte $3e ; 0111110 011 1110
.byte $00
; t $74
.byte $00 ; 0000000 000 0000
.byte $04 ; 0010000 000 0100
.byte $1e ; 0111100 001 1110
.byte $04 ; 0010000 000 0100
.byte $04 ; 0010000 000 0100
.byte $24 ; 0010010 010 0100
.byte $18 ; 0001100 001 1000
.byte $00
; u $75
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $32 ; 0100110 011 0010
.byte $2c ; 0011010 010 1100
.byte $00
; v $76
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $14 ; 0010100 001 0100
.byte $08 ; 0001000 000 1000
.byte $00
; w $77
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $2a ; 0101010 010 1010
.byte $2a ; 0101010 010 1010
.byte $36 ; 0110110 011 0110
.byte $00
; x $78
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $22 ; 0100010 010 0010
.byte $14 ; 0010100 001 0100
.byte $08 ; 0001000 000 1000
.byte $14 ; 0010100 001 0100
.byte $22 ; 0100010 010 0010
.byte $00
; y $79
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $22 ; 0100010 010 0010
.byte $3c ; 0011110 011 1100
.byte $20 ; 0000010 010 0000
.byte $1c ; 0011100 001 1100
; z $7A
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $3e ; 0111110 011 1110
.byte $10 ; 0000100 001 0000
.byte $08 ; 0001000 000 1000
.byte $04 ; 0010000 000 0100
.byte $3e ; 0111110 011 1110
.byte $00
; { $7b
.byte $38 ; 0001110 011 1000
.byte $0c ; 0011000 000 1100
.byte $0c ; 0011000 000 1100
.byte $06 ; 0110000 000 0110
.byte $0c ; 0011000 000 1100
.byte $0c ; 0011000 000 1100
.byte $38 ; 0001110 011 1000
.byte $00
; | $7c
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
.byte $08 ; 0001000 000 1000
; } $7d
.byte $0e ; 0111000 000 1110
.byte $18 ; 0001100 001 1000
.byte $18 ; 0001100 001 1000
.byte $30 ; 0000110 011 0000
.byte $18 ; 0001100 001 1000
.byte $18 ; 0001100 001 1000
.byte $0e ; 0111000 000 1110
.byte $00
; ~ $7e
.byte $2c ; 0011010 010 1100
.byte $1a ; 0101100 001 1010
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00 ; 0000000 000 0000
.byte $00
; del $7F
.byte $00 ; 0000000 000 0000
.byte $2a ; 0101010 010 1010
.byte $14 ; 0010100 001 0100
.byte $2a ; 0101010 010 1010
.byte $14 ; 0010100 001 0100
.byte $2a ; 0101010 010 1010
.byte $00 ; 0000000 000 0000
.byte $00

View File

@ -0,0 +1,308 @@
; HGR Rectangle
; VGI Rectangle test
COLOR_MODE = TEMP0
OTHER_MASK = TEMP1
XRUN = TEMP2
div7_table = $B000
mod7_table = $B100
; FAST
;=================================
; Simple Rectangle
;=================================
; VGI_RCOLOR = P0
; VGI_RX1 = P1
; VGI_RY1 = P2
; VGI_RXRUN = P3
; VGI_RYRUN = P4
; VGI_RCOLOR2 = P5 ; only for dither
;==================================
; VGI Simple Rectangle
;==================================
vgi_simple_rectangle:
lda #0
sta COLOR_MODE
simple_rectangle_loop:
lda COLOR_MODE
beq simple_colors
bmi striped_colors
bpl handle_dither
simple_colors:
lda VGI_RCOLOR
asl ; nibble swap by david galloway
adc #$80
rol
asl
adc #$80
rol
sta VGI_RCOLOR
and #$f
tax
lda COLORTBL,X
sta HGR_COLOR
jmp done_colors
handle_dither:
lda COUNT
and #$1
beq deven_color
dodd_color:
lda VGI_RCOLOR
jmp dsave_color
deven_color:
lda VGI_RCOLOR2
dsave_color:
sta HGR_COLOR
inc COUNT
jmp done_colors
striped_colors:
; don't need to do anything here?
done_colors:
; get ROW into (GBASL)
ldx VGI_RX1 ; X1 into X
lda VGI_RY1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
; Y is already the RX1/7
; adjust color if in striped mode
lda COLOR_MODE
bpl not_striped
jsr swap_colors
not_striped:
; copy the XRUN
lda VGI_RXRUN
sta XRUN
inc XRUN ; needed because we compare with beq/bne
; check if narrow corner case where begin and end same block
; if RX%7 + XRUN < 8
ldx VGI_RX1
lda mod7_table,X
clc
adc XRUN
cmp #8
bcs not_corner
corner:
; want to use MASK of left_mask, MOD7 and 7-XRUN
lda mod7_table,X
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
ldx XRUN
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
jmp done_row ; that's all
not_corner:
; see if not starting on boundary
ldx VGI_RX1
lda mod7_table,X
beq draw_run
; handle not full left border
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
eor (GBASL),Y
sta (GBASL),Y
iny ; move to next
; adjust RUN length by 7- mod7
txa ; load mod7
eor #$ff
sec
adc #7
eor #$ff
sec
adc XRUN
sta XRUN
; lda HGR_BITS ; cycle colors for next
; jsr COLOR_SHIFT
jsr swap_colors
;no_shift:
; draw common
draw_run:
lda XRUN
cmp #7
bcc draw_right ; blt
lda HGR_BITS ; get color
sta (GBASL),Y ; store out
; jsr COLOR_SHIFT ; shift colors
iny ; move to next block
jsr swap_colors
lda XRUN ; take 7 off the run
sec
sbc #7
sta XRUN
jmp draw_run
; draw rightmost
draw_right:
beq done_row
; lda HGR_BITS
; jsr COLOR_SHIFT
; see if not starting on boundary
ldx XRUN
tax
lda (GBASL),Y
eor HGR_BITS
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
done_row:
inc VGI_RY1
dec VGI_RYRUN
;bne simple_rectangle_loop
beq done_done
jmp simple_rectangle_loop
done_done:
rts
;==========================
; swap colors
;==========================
swap_colors:
lda COLOR_MODE
bmi swap_colors_striped
lda HGR_BITS ; get color
jsr COLOR_SHIFT ; shift colors
rts
swap_colors_striped:
tya
and #1
bne swap_odd
lda VGI_RCOLOR
jmp swap_done
swap_odd:
lda VGI_RCOLOR2
swap_done:
sta HGR_BITS
rts
;=====================
; make /7 %7 tables
;=====================
vgi_init:
vgi_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
rts
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF

View File

@ -0,0 +1,5 @@
wait_until_keypress:
lda KEYPRESS ; 4
bpl wait_until_keypress ; 3
bit KEYRESET ; clear the keyboard buffer
rts ; 6