From f2f17259babdfa8d1ebb2c57241d46e6360aa0d3 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 23 Aug 2023 16:18:49 -0400 Subject: [PATCH] hgr_font: trying some things out --- games/sb/cliff/CLIFF.NOTES | 3 + graphics/hgr/hgr_font_4am/Makefile | 34 +++ graphics/hgr/hgr_font_4am/bios_test.s | 208 ++++++++++++++++++ graphics/hgr/hgr_font_4am/graphics/Makefile | 23 ++ .../hgr/hgr_font_4am/graphics/a2_energy.png | Bin 0 -> 894 bytes graphics/hgr/hgr_font_4am/hardware.inc | 102 +++++++++ graphics/hgr/hgr_font_4am/hello.bas | 4 + graphics/hgr/hgr_font_4am/zp.inc | 39 ++++ graphics/hgr/hgr_font_4am/zx02_optim.s | 163 ++++++++++++++ 9 files changed, 576 insertions(+) create mode 100644 games/sb/cliff/CLIFF.NOTES create mode 100644 graphics/hgr/hgr_font_4am/Makefile create mode 100644 graphics/hgr/hgr_font_4am/bios_test.s create mode 100644 graphics/hgr/hgr_font_4am/graphics/Makefile create mode 100644 graphics/hgr/hgr_font_4am/graphics/a2_energy.png create mode 100644 graphics/hgr/hgr_font_4am/hardware.inc create mode 100644 graphics/hgr/hgr_font_4am/hello.bas create mode 100644 graphics/hgr/hgr_font_4am/zp.inc create mode 100644 graphics/hgr/hgr_font_4am/zx02_optim.s diff --git a/games/sb/cliff/CLIFF.NOTES b/games/sb/cliff/CLIFF.NOTES new file mode 100644 index 00000000..80e634c4 --- /dev/null +++ b/games/sb/cliff/CLIFF.NOTES @@ -0,0 +1,3 @@ +can't exit once there + first screen can't go through branches, on 2nd+3rd can? + diff --git a/graphics/hgr/hgr_font_4am/Makefile b/graphics/hgr/hgr_font_4am/Makefile new file mode 100644 index 00000000..f142d30f --- /dev/null +++ b/graphics/hgr/hgr_font_4am/Makefile @@ -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 + diff --git a/graphics/hgr/hgr_font_4am/bios_test.s b/graphics/hgr/hgr_font_4am/bios_test.s new file mode 100644 index 00000000..fe0ae190 --- /dev/null +++ b/graphics/hgr/hgr_font_4am/bios_test.s @@ -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+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 OUTH + + jsr hgr_put_string + + jsr hgr_put_string + + jsr hgr_put_string + + lda #test1 + sta OUTH + + jsr hgr_put_string + + 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" diff --git a/graphics/hgr/hgr_font_4am/graphics/Makefile b/graphics/hgr/hgr_font_4am/graphics/Makefile new file mode 100644 index 00000000..f0f9a0e0 --- /dev/null +++ b/graphics/hgr/hgr_font_4am/graphics/Makefile @@ -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 diff --git a/graphics/hgr/hgr_font_4am/graphics/a2_energy.png b/graphics/hgr/hgr_font_4am/graphics/a2_energy.png new file mode 100644 index 0000000000000000000000000000000000000000..e0064a3896a07ad27f7a51d7763b2d14bb41f663 GIT binary patch literal 894 zcmeAS@N?(olHy`uVBq!ia0y~yV3Yu|53n!;N!?wEoXJIEZ3zue`j#aAX!cp_l#Emv2WY|*X&#VcHEt!BjhV)d1pBqHv9aO;By z$CIueJQ^9!9_}dchoP{vFsNjr(EsToQAa8Y?(~;`mn(nIurM@vmZ%rgti0JbOT5mA zhaLSF-XiG2QP`52CRsdbO5^(!jFlsyN>72IjzTSW1RJD)8`|BNgMAR_Tt~%wNlVu_;`r#@*2hW z8&6esZw|}eaL)E8x3X((>de-OJc zO0)OOFWY)U&|nL1Oia0HD*uiKnyeK(WgjqBgaUj*T!FOoX~rie|Nj5~ ze>R#?de*;*^PMGuqMQXDk;M!Q5Hy~NYkmHjz~xQL)c;zrTwKq1Kz z*N775{M_8syb=cIqSVBa)D(sC%#sWRcTeAd@J2pyV9a}ax;TbZ+9G{hx|L!}^*qG3B+#_Wf`R@7W;r`;&F3;ijxKPD=;VeH_WJ41Nl@885#+ zr7ZD|>D4udJDzQs6~w7L^K#Y6j6*kmsM;QWBJtXMdfX?S+a9n z4NloV6nbW-T00|Ezbmyk!!4#~Y5eR$-x;aK(~?>WFTPvVI0dAQyB#4c;W z==ziI&mEa)zi?jF#rdzFo~oFfcJlE8`3rhyD!ir_E-<)wOeBpFlw)v#@M?y9KEuBj S-!H8KDe-jmb6Mw<&;$Uev3+R( literal 0 HcmV?d00001 diff --git a/graphics/hgr/hgr_font_4am/hardware.inc b/graphics/hgr/hgr_font_4am/hardware.inc new file mode 100644 index 00000000..63eb36df --- /dev/null +++ b/graphics/hgr/hgr_font_4am/hardware.inc @@ -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 + diff --git a/graphics/hgr/hgr_font_4am/hello.bas b/graphics/hgr/hgr_font_4am/hello.bas new file mode 100644 index 00000000..2c3f3741 --- /dev/null +++ b/graphics/hgr/hgr_font_4am/hello.bas @@ -0,0 +1,4 @@ +5 HOME +10 PRINT CHR$(4)"BRUN BIOS_TEST" + + diff --git a/graphics/hgr/hgr_font_4am/zp.inc b/graphics/hgr/hgr_font_4am/zp.inc new file mode 100644 index 00000000..1c181aca --- /dev/null +++ b/graphics/hgr/hgr_font_4am/zp.inc @@ -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 + + diff --git a/graphics/hgr/hgr_font_4am/zx02_optim.s b/graphics/hgr/hgr_font_4am/zx02_optim.s new file mode 100644 index 00000000..8b88caf8 --- /dev/null +++ b/graphics/hgr/hgr_font_4am/zx02_optim.s @@ -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