sb: ill advised new project

This commit is contained in:
Vince Weaver 2023-03-05 20:54:41 -05:00
parent 076a305205
commit 5cfabce59c
8 changed files with 554 additions and 0 deletions

36
games/sb/Makefile Normal file
View File

@ -0,0 +1,36 @@
include ../../Makefile.inc
ZX02 = ~/research/6502_compression/zx02.git/build/zx02
PNG_TO_HGR = ../../utils/hgr-utils/png2hgr
LINKER_SCRIPTS = ../../linker_scripts
DOS33 = ../../utils/dos33fs-utils/dos33
EMPTY_DISK = ../../empty_disk/empty.dsk
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
all: sb.dsk
####
sb.dsk: HELLO SB
cp $(EMPTY_DISK) sb.dsk
$(DOS33) -y sb.dsk SAVE A HELLO
$(DOS33) -y sb.dsk BSAVE -a 0x0c00 SB
####
SB: sb.o
ld65 -o SB sb.o -C $(LINKER_SCRIPTS)/apple2_c00.inc
sb.o: sb.s zx02_optim.s \
zp.inc hardware.inc
ca65 -o sb.o sb.s -l sb.lst
####
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
####
clean:
rm -f *.lst *.o SB *~

View File

@ -0,0 +1,24 @@
include ../../../Makefile.inc
ZX02 = ~/research/6502_compression/zx02.git/build/zx02
PNG_TO_HGR = ../../../utils/hgr-utils/png2hgr
LINKER_SCRIPTS = ../../../linker_scripts
DOS33 = ../../../utils/dos33fs-utils/dos33
EMPTY_DISK = ../../../empty_disk/empty.dsk
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
all: strongbad_sample.hgr.zx02
####
strongbad_sample.hgr.zx02: strongbad_sample.hgr
$(ZX02) strongbad_sample.hgr strongbad_sample.hgr.zx02
strongbad_sample.hgr: strongbad_sample.png
$(PNG_TO_HGR) strongbad_sample.png > strongbad_sample.hgr
####
clean:
rm -f *~ *.o *.lst

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

84
games/sb/hardware.inc Normal file
View File

@ -0,0 +1,84 @@
;; 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
SPEAKER = $C030
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
;; BASIC ROUTINES
NORMAL = $F273
;; 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
TEXT = $FB36
TABV = $FB5B ;; VTAB to A
BASCALC = $FBC1 ;;
VTAB = $FC22 ;; VTAB to CV
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
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

2
games/sb/hello.bas Normal file
View File

@ -0,0 +1,2 @@
5 HOME
105 PRINT CHR$ (4)"BRUN SB"

64
games/sb/sb.s Normal file
View File

@ -0,0 +1,64 @@
; Yet Another HR project
;
; by deater (Vince Weaver) <vince@deater.net>
.include "zp.inc"
.include "hardware.inc"
hires_start:
;===================
; set graphics mode
;===================
jsr HOME
bit HIRES
bit FULLGR
bit SET_GR
bit PAGE0
;===================
; Load graphics
;===================
load_loop:
;=============================
;==========================
; Load Image
;===========================
load_image:
; size in ldsizeh:ldsizel (f1/f0)
; comp_data = $a000
out_addr = $2000
jsr full_decomp
rts
wait_until_keypress:
lda KEYPRESS ; 4
bpl wait_until_keypress ; 3
bit KEYRESET ; clear the keyboard buffer
which_ok:
jmp load_loop
.include "zx02_optim.s"
comp_data:
.incbin "graphics/strongbad_sample.hgr.zx02"

200
games/sb/zp.inc Normal file
View File

@ -0,0 +1,200 @@
;; Zero Page
FRAMEBUFFER = $00 ; $00 - $0F
;; LZ4 addresses
FLAME_STATE = $00
FLAME1 = $01
FLAME2 = $02
FLAME3 = $03
FLAME4 = $04
FLAME5 = $05
LZ4_SRC = $00
LZ4_DST = $02
LZ4_END = $04
COUNT = $06
DELTA = $08
;; Zero page monitor routines addresses
WNDLFT = $20
WNDWDTH = $21
WNDTOP = $22
WNDBTM = $23
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
H2 = $2C
V2 = $2D
MASK = $2E
COLOR = $30
;INVFLG = $32
; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d
; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8
; DOS33: Confirmed kills $68
RWTSL = $60
RWTSH = $61
DOSBUFL = $62
DOSBUFH = $63
FILEML = $64
FILEMH = $65
FRAME = $60
FRAMEH = $61
WAITING = $62
LETTERL = $63
LETTERH = $64
LETTERX = $65
LETTERY = $66
LETTERD = $67
LETTER = $68
BLARGH = $69
;FACTOR_I = $66
;FACTOR_F = $67
;DX_I = $68
;DX_F = $69
;SPACEX_I = $6A
;SPACEX_F = $6B
;CX_I = $6C
;CX_F = $6D
;DY_I = $6E
;DY_F = $6F
ZPOS = $78
REGISTER_DUMP = $70
A_FINE_TONE = $70
A_COARSE_TONE = $71
B_FINE_TONE = $72
B_COARSE_TONE = $73
C_FINE_TONE = $74
C_COARSE_TONE = $75
NOISE = $76
ENABLE = $77
A_VOLUME = $78
B_VOLUME = $79
C_VOLUME = $7A
ENVELOPE_FINE = $7B
ENVELOPE_COARSE = $7C
ENVELOPE_SHAPE = $7D
COPY_OFFSET = $7E
DECODER_STATE = $7F
REGISTER_DUMP2 = $80
A_FINE_TONE2 = $80
A_COARSE_TONE2 = $81
B_FINE_TONE2 = $82
B_COARSE_TONE2 = $83
C_FINE_TONE2 = $84
C_COARSE_TONE2 = $85
NOISE2 = $86
ENABLE2 = $87
A_VOLUME2 = $88
B_VOLUME2 = $89
C_VOLUME2 = $8A
ENVELOPE_FINE2 = $8B
ENVELOPE_COARS2 = $8C
ENVELOPE_SHAPE2 = $8D
LYRICSL = $8E
LYRICSH = $8F
FRAME_COUNT = $90
MB_VALUE = $91
MB_ADDRL = $91
MB_ADDRH = $92
DONE_PLAYING = $93
MB_CHUNK_OFFSET = $94
MB_FRAME = $94
MB_PATTERN = $95
CHUNKSIZE = $95
LZ4_DONE = $96
DECODE_ERROR = $97
COPY_TIME = $98
DECOMPRESS_TIME = $99
TIME_TAKEN = $9A
LYRICS_ACTIVE = $9B
;FORTYCOL = $9C
CURSOR = $9D
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
;COLOR1 = $E0
;COLOR2 = $E1
;MATCH = $E2
XX = $E3
YY = $E4
HGR_COLOR = $E4
;SHIPY = $E4
;YADD = $E5
;LOOP = $E6
;MEMPTRL = $E7
;MEMPTRH = $E8
;NAMEL = $E9
;NAMEH = $EA
;NAMEX = $EB
;CHAR = $EC
STATE = $ED
DISP_PAGE = $ED
DRAW_PAGE = $EE
OFFSET = $EF
;FIRST = $F0
LASTKEY = $F1
PADDLE_STATUS = $F2
SPRITETEMP = $F2
XPOS = $F3
YPOS = $F4
TEMP = $FA
TEMPY = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
; read any file slot 6 version
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013,2018
; modified to assembled with ca64 -- vmw
; added code to patch it to run from current disk slot -- vmw
adrlo = $26 ; constant from boot prom
adrhi = $27 ; constant from boot prom
tmpsec = $3c ; constant from boot prom
reqsec = $3d ; constant from boot prom
sizelo = $44
sizehi = $45
secsize = $46
ldsizel = $f0
ldsizeh = $f1
namlo = $fb
namhi = $fc
step = $fd ; state for stepper motor
tmptrk = $fe ; temporary copy of current track
phase = $ff ; current phase for /seek

144
games/sb/zx02_optim.s Normal file
View File

@ -0,0 +1,144 @@
; 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, <comp_data, >comp_data, <out_addr, >out_addr, $80
;--------------------------------------------------
; Decompress ZX0 data (6502 optimized format)
full_decomp:
; 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