xmas2019: closer

This commit is contained in:
Vince Weaver 2019-12-20 14:36:47 -05:00
parent daf6c3ff48
commit ef9d0347d5
3 changed files with 200 additions and 25 deletions

View File

@ -3,6 +3,7 @@ include ../Makefile.inc
DOS33 = ../dos33fs-utils/dos33
B2D = ../bmp2dhr/b2d
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
PNG_TO_40x96 = ../gr-utils/png_to_40x96
all: xmas2019.dsk sine_table
@ -41,21 +42,16 @@ XMAS2019: xmas2019.o
ld65 -o XMAS2019 xmas2019.o -C ../linker_scripts/apple2_4000.inc
xmas2019.o: xmas2019.s \
delay_a.s vapor_lock.s
#gr_hline.s state_machine.s move_letters.s
delay_a.s vapor_lock.s message.inc gr_unrle.s
ca65 -o xmas2019.o xmas2019.s -l xmas2019.lst
#####
#background_final.inc: background_final.png
# $(PNG_TO_40x48D) asm background_final.png bg_final > background_final.inc
message.inc: message.png
$(PNG_TO_40x96) asm message.png message > message.inc
####
FIREWORKS.BAS: fireworks.bas
../asoft_basic-utils/tokenize_asoft < fireworks.bas > FIREWORKS.BAS
####
HELLO: hello.bas

137
xmas_2019/gr_unrle.s Normal file
View File

@ -0,0 +1,137 @@
;=================
; load RLE image
;=================
; Output is A:00 (assume page aligned)
; Input is in GBASH/GBASL
; format: first byte=xsize
; A0,X,Y means run of X bytes of Y color
; A1 means end of file
; A2-AF,X means run of low nibble, X color
; if high nibble not A: just display color
; CV = current Y
; CH = max xsize (usually 40)
; TEMP = page
; TEMPY= current X
; RECALC, I changed gr_offsets
; 82 + 10 +
; special short: 38+7+ 27+ 27*run +5+2
; special long: 38+7+24+27+ 27*run +5+2
; nospecial: 38+6+19+(cross line*58)+5+2
load_rle_gr:
sec ; 2
sbc #4 ; adjust page to write to ; 2
; to match gr_offsets
sta TEMP ; 3
ldy #$0 ; init Y to 0 ; 2
sty CV ; 3
jsr load_and_increment ; load xsize ; 6+19
sta CH ; 3
jsr unrle_new_y ; 6+36
;============
; 82
rle_loop:
jsr load_and_increment ; 6+19
tax ; 2
cmp #$A1 ; if 0xa1 ; 2
beq rle_done ; we are done ; 3
; -1
and #$f0 ; mask ; 2
cmp #$a0 ; see if special AX ; 2
beq decompress_special ; 3
;===========
; 38
; -1
; not special, just color
txa ; put color back in A ; 2
ldx #$1 ; only want to print 1 ; 2
bne decompress_run ; bra ; 3
decompress_special:
txa ; put read value back in A ; 2
and #$0f ; check if was A0 ; 2
bne decompress_color ; if A0 need to read run, color ; 3
;===
; 7
decompress_large: ; -1
jsr load_and_increment ; run length now in A ; 6+19
decompress_color:
tax ; put runlen into X ; 2
jsr load_and_increment ; get color into A ; 6+19
decompress_run:
rle_run_loop:
sta (BASL),y ; write out the value ; 6
inc BASL ; 5
dec TEMPY ; 5
bne rle_not_eol ; if less then keep going ; 3
;====
; 19
; -1
; if here, we are > max_X
inc CV ; 5
pha ; 3
jsr unrle_new_y ; 6+36
pla ; 4
;===
;53
rle_not_eol:
dex ; 2
bne rle_run_loop ; if not zero, keep looping ; 3
;==
; 5
; -1
beq rle_loop ; and branch always ; 3
rle_done:
lda #$15 ; move cursor somewhere sane ; 2
sta CV ; 3
rts ; 6
;========================
; common case = 19
load_and_increment:
lda (GBASL),Y ; 5+
inc GBASL ; 5
bne lai_no_oflo ; 3
; -1
inc GBASH ; 5
lai_no_oflo:
rts ; 6
;========================
; common case = 36
unrle_new_y:
ldy CV ; 3
lda gr_offsets_l,Y ; 4+
sta BASL ; 3
lda gr_offsets_h,Y ; 4+
clc ; 2
adc TEMP ; adjust for page ; 3
sta BASH ; 3
lda CH ; 3
sta TEMPY ; 3
ldy #0 ; 2
rts ; 6
;===========
; 36

View File

@ -27,6 +27,7 @@ CMASK2 = $F3
WHICH_Y = $F4
FRAME = $F5
TEMPY = $F6
TEMP = $F7
HGR = $F3E2
@ -72,6 +73,28 @@ snow_init_loop:
bpl snow_init_loop
;=============================
; Load graphic page0
lda #<message_low
sta GBASL
lda #>message_low
sta GBASH
lda #$c
jsr load_rle_gr
;=============================
; Load graphic page1
lda #<message_high
sta GBASL
lda #>message_high
sta GBASH
lda #$10
jsr load_rle_gr
;==========================================================
;==========================================================
; Vapor Lock
@ -82,21 +105,26 @@ snow_init_loop:
; vapor lock returns with us at beginning of hsync in line
; 114 (7410 cycles), so with 5070 lines to go to vblank
; then we want another 4050 cycles to end, so 9120
; then we want another 4550 cycles to end, so 9620
; 9620
; -9298
;=======
; 322
jsr gr_copy_to_current ; 6+ 9292
;=================================
; do nothing
;=================================
; and take 9120 cycles to do it
; and take 322 cycles to do it
do_nothing:
; Try X=139 Y=13 cycles=9114R6
; Try X=1 Y=29 cycles=320 R2
nop
nop
nop
ldy #13 ; 2
loop1: ldx #139 ; 2
ldy #29 ; 2
loop1: ldx #1 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
@ -105,8 +133,9 @@ loop2: dex ; 2
;=============================================
;=============================================
;=============================================
display_loop:
@ -134,8 +163,19 @@ bloop2: dex ; 2
ldx #127 ; 2
middle_loop:
bit HIRES ; 4
; 27
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
bit LORES ; 4
@ -154,13 +194,6 @@ middle_loop:
lda COLOR
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
lda COLOR ; 3
dex ; 2
@ -734,3 +767,12 @@ pixel_lookup:
.include "vapor_lock.s"
.include "delay_a.s"
.include "random16.s"
.include "message.inc"
.include "gr_unrle.s"
.include "gr_copy.s"
; include music
.align $100
.incbin "./music/jingle.pt3"