hgr_font: trying some things out

This commit is contained in:
Vince Weaver 2023-08-23 16:18:49 -04:00
parent 2f79555324
commit f2f17259ba
9 changed files with 576 additions and 0 deletions

View File

@ -0,0 +1,3 @@
can't exit once there
first screen can't go through branches, on 2nd+3rd can?

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_font4.dsk
hgr_font4.dsk: HELLO BIOS_TEST
cp $(EMPTY_DISK)/empty.dsk hgr_font4.dsk
$(DOS33) -y hgr_font4.dsk SAVE A HELLO
$(DOS33) -y hgr_font4.dsk BSAVE -a 0x6000 BIOS_TEST
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
BIOS_TEST: bios_test.o
ld65 -o BIOS_TEST bios_test.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
bios_test.o: bios_test.s hgr_font.s hgr_1x8_sprite.s
ca65 -o bios_test.o bios_test.s -l bios_test.lst
###
clean:
rm -f *~ *.o *.lst HELLO BIOS_TEST

View File

@ -0,0 +1,208 @@
; Fake BIOS screen
; for another project
.include "zp.inc"
.include "hardware.inc"
bios_test:
;===================
; set graphics mode
;===================
jsr HOME
bit HIRES
bit FULLGR
bit SET_GR
bit PAGE1
;===================
; Load graphics
;===================
lda #<graphics_data
sta ZX0_src
lda #>graphics_data
sta ZX0_src+1
lda #$20 ; temporarily load to $2000
jsr full_decomp
end:
jmp end
.if 0
jsr vgi_make_tables
jsr HGR
; 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"
.endif
.include "zx02_optim.s"
graphics_data:
.incbin "graphics/a2_energy.hgr.zx02"

View File

@ -0,0 +1,23 @@
include ../../../../Makefile.inc
ZX02 = ~/research/6502_compression/zx02.git/build/zx02 -f
PNG_TO_HGR = ../../../../utils/hgr-utils/png2hgr
PNG2GR = ../../../../utils/gr-utils/png2gr
PNG2SPRITES = ../../../../utils/gr-utils/png2sprites
HGR_SPRITE = ../../../../utils/hgr-utils/hgr_make_sprite
all: a2_energy.hgr.zx02
####
a2_energy.hgr.zx02: a2_energy.hgr
$(ZX02) a2_energy.hgr a2_energy.hgr.zx02
a2_energy.hgr: a2_energy.png
$(PNG_TO_HGR) a2_energy.png > a2_energy.hgr
####
clean:
rm -f *~ *.o *.zx02 *.lst

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

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
PAGE1 = $C054
PAGE2 = $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)"BRUN BIOS_TEST"

View File

@ -0,0 +1,39 @@
; zx02 code
offset = $10
offseth = $11
ZX0_src = $12
ZX0_dst = $14
ZX0_srch= $15
bitr = $16
pntr = $17
pntrh = $18
;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

View File

@ -0,0 +1,163 @@
; De-compressor for ZX02 files
; ----------------------------
;
; Decompress ZX02 data (6502 optimized format), optimized for speed and size
; 138 bytes code, 58.0 cycles/byte in test file.
;
; Compress with:
; zx02 input.bin output.zx0
;
; (c) 2022 DMSC
; Code under MIT license, see LICENSE file.
;ZP=$80
;offset = ZP+0
;ZX0_src = ZP+2
;ZX0_dst = ZP+4
;bitr = ZP+6
;pntr = ZP+7
; Initial values for offset, source, destination and bitr
;zx0_ini_block:
; .byte $00, $00 ; offset
;comp_data:
; .byte $0, $0 ; zx0_src
;out_addr:
; .byte $0, $0 ; zx0_dst
; .byte $80 ; bitr
;--------------------------------------------------
; Decompress ZX0 data (6502 optimized format)
; destination page in A
full_decomp:
sta ZX0_dst+1
ldy #$80
sty bitr
ldy #0 ; always on page boundary
sty ZX0_dst
sty offset
sty offset+1
; Y needs to be 0 here
; Get initialization block
; ldy #7
;copy_init: lda zx0_ini_block-1, y
; sta offset-1, y
; dey
; bne copy_init
; Decode literal: Ccopy next N bytes from compressed file
; Elias(length) byte[1] byte[2] ... byte[N]
decode_literal:
jsr get_elias
cop0: lda (ZX0_src), y
inc ZX0_src
bne plus1
inc ZX0_src+1
plus1: sta (ZX0_dst),y
inc ZX0_dst
bne plus2
inc ZX0_dst+1
plus2: dex
bne cop0
asl bitr
bcs dzx0s_new_offset
; Copy from last offset (repeat N bytes from last offset)
; Elias(length)
jsr get_elias
dzx0s_copy:
lda ZX0_dst
sbc offset ; C=0 from get_elias
sta pntr
lda ZX0_dst+1
sbc offset+1
sta pntr+1
cop1:
lda (pntr), y
inc pntr
bne plus3
inc pntr+1
plus3: sta (ZX0_dst),y
inc ZX0_dst
bne plus4
inc ZX0_dst+1
plus4: dex
bne cop1
asl bitr
bcc decode_literal
; Copy from new offset (repeat N bytes from new offset)
; Elias(MSB(offset)) LSB(offset) Elias(length-1)
dzx0s_new_offset:
; Read elias code for high part of offset
jsr get_elias
beq exit ; Read a 0, signals the end
; Decrease and divide by 2
dex
txa
lsr ; @
sta offset+1
; Get low part of offset, a literal 7 bits
lda (ZX0_src), y
inc ZX0_src
bne plus5
inc ZX0_src+1
plus5:
; Divide by 2
ror ; @
sta offset
; And get the copy length.
; Start elias reading with the bit already in carry:
ldx #1
jsr elias_skip1
inx
bcc dzx0s_copy
; Read an elias-gamma interlaced code.
; ------------------------------------
get_elias:
; Initialize return value to #1
ldx #1
bne elias_start
elias_get: ; Read next data bit to result
asl bitr
rol ; @
tax
elias_start:
; Get one bit
asl bitr
bne elias_skip1
; Read new bit from stream
lda (ZX0_src), y
inc ZX0_src
bne plus6
inc ZX0_src+1
plus6: ;sec ; not needed, C=1 guaranteed from last bit
rol ;@
sta bitr
elias_skip1:
txa
bcs elias_get
; Got ending bit, stop reading
exit:
rts