sa: have 40col working

This commit is contained in:
Vince Weaver 2018-05-23 14:07:19 -04:00
parent 6cd1a8e424
commit 3ab5969867
8 changed files with 231 additions and 193 deletions

View File

@ -16,7 +16,7 @@ STILL_ALIVE: still_alive.o
still_alive.o: still_alive.s \
../asm_routines/mockingboard.s \
../asm_routines/lz4_decode.s \
../asm_routines/keypress_minimal.s \
display_art.s display_lyrics.s \
interrupt_handler.s \
ascii_art.inc lyrics.inc zp.inc
ca65 -o still_alive.o still_alive.s -l still_alive.lst

View File

@ -4,12 +4,16 @@ Challenges:
+ Printing the ASCII art simple code (takes longer than 50Hz)
Goal: Everything inside of 16k
Goal: Binary fits in 16k (16384 bytes)
note size (bytes)
--------------------- ------
initial music player: 2078
add raw ascii art: 9142
add 3-channel music+lyrics,then slim a bit: 18787
initial 40 col support: 18864
have art loading properly 40col: 18910
Memory Map

View File

@ -1,6 +1,7 @@
+ Opening graphics (BASIC)
+ 80-column support
+ compressed ascii art
+ No lowercase for 40-column option?
+ six-channel support
generic? or combine it?
+ 40 column support

182
still_alive/display_art.s Normal file
View File

@ -0,0 +1,182 @@
;============================
; Draw Lineart around edges
;============================
setup_edges:
lda FORTYCOL
bne fortycol_lineart
eightycol_lineart:
; Draw top line
lda #' '+$80
sta dal_first+1
lda #'-'+$80
sta dal_second+1
jsr draw_ascii_line
; Draw columns
ldy #20
lda #'|'+$80
sta dal_first+1
lda #' '+$80
sta dal_second+1
line_loop:
jsr draw_ascii_line
dey
bne line_loop
; Draw bottom line
lda #' '+$80
sta dal_first+1
lda #'-'+$80
sta dal_second+1
jsr draw_ascii_line
jsr word_bounds
rts
fortycol_lineart:
jsr word_bounds
rts
;=====================
; Draw ascii line art
;
; trashes A,X
draw_ascii_line:
dal_first:
lda #'|'+$80
jsr COUT1
ldx #38
dal_second:
lda #' '+$80
dal_loop:
jsr COUT1
dex
bne dal_loop
lda dal_first+1
jsr COUT1
rts
;=============================
; Draw ASCII art
;=============================
; Eventually will be LZ4 encoded to save room
; It's 7063 bytes of data unencoded
; A is which one to draw
; Decode it to 0x800 (text page 2) which we aren't using
; and we shouldn't have to worry about screen holes
draw_ascii_art:
sty TEMPY
asl ; point to ascii art we want
tay
dey
dey
lda ascii_art,Y
sta OUTL
lda ascii_art+1,Y
sta OUTH
ldy #8 ; put it at line 4 (2-byte addresses)
art_line_loop:
lda gr_offsets,Y ; load offset of line
sta GBASL
lda gr_offsets+1,Y
sta GBASH
iny
iny
sty YY
ldy #0
ascii_loop:
lda (OUTL),Y ; see if done
beq done_ascii_total
cmp #13+$80 ; see if line feed
beq done_ascii_line
sta (GBASL),Y ; if not, just draw
iny ; point to next char
jmp ascii_loop
done_ascii_line:
iny
tya ; bump art pointer by Y
clc
adc OUTL
sta OUTL
lda #0
adc OUTH
sta OUTH
lda #' '+$80
ascii_pad: ; pad out with spaces for 40 columns
cpy #40
bcs done_pad
sta (GBASL),Y
iny
jmp ascii_pad
done_pad:
ldy YY ; load Y value
jmp art_line_loop
done_ascii_total:
ldy TEMPY
rts
;============================
; Setup Art Bounds
;============================
art_bounds:
lda FORTYCOL
bne fortycol_art_bounds
eightycol_art_bounds:
; on 80 column, art goes from 39,1 to 40,23 (????)
lda #2
sta WNDLFT
lda #35
sta WNDWDTH
lda #1
sta WNDTOP
lda #21
sta WNDBTM
rts
fortycol_art_bounds:
; on 40 column, art goes from 0,4 to 40,24
lda #0
sta WNDLFT
lda #40
sta WNDWDTH
lda #4
sta WNDTOP
lda #24
sta WNDBTM
rts

View File

@ -0,0 +1,37 @@
;============================
; Setup Word Bounds
;============================
word_bounds:
lda FORTYCOL
bne fortycol_word_bounds
eightycol_word_bounds:
; on 80 column, words go from 2,1 to 35,21
lda #2
sta WNDLFT
lda #35
sta WNDWDTH
lda #1
sta WNDTOP
lda #21
sta WNDBTM
rts
fortycol_word_bounds:
; on 40 column, words go from 1,0 to 35,4
lda #1
sta WNDLFT
lda #35
sta WNDWDTH
lda #0
sta WNDTOP
lda #4
sta WNDBTM
rts

Binary file not shown.

View File

@ -113,50 +113,7 @@ mockingboard_found:
; Draw Lineart around edges
;============================
lda FORTYCOL
bne fortycol_lineart
eightycol_lineart:
; Draw top line
lda #' '+$80
sta dal_first+1
lda #'-'+$80
sta dal_second+1
jsr draw_ascii_line
; Draw columns
ldy #20
lda #'|'+$80
sta dal_first+1
lda #' '+$80
sta dal_second+1
line_loop:
jsr draw_ascii_line
dey
bne line_loop
; Draw bottom line
lda #' '+$80
sta dal_first+1
lda #'-'+$80
sta dal_second+1
jsr draw_ascii_line
jsr word_bounds
jmp done_lineart
fortycol_lineart:
jsr word_bounds
done_lineart:
jsr setup_edges
jsr HOME
@ -369,152 +326,6 @@ page_copy_loop:
; 2+14*256+6+29= 3621
;=====================
; Draw ascii line art
;
; trashes A,X
draw_ascii_line:
dal_first:
lda #'|'+$80
jsr COUT1
ldx #38
dal_second:
lda #' '+$80
dal_loop:
jsr COUT1
dex
bne dal_loop
lda dal_first+1
jsr COUT1
rts
;=============================
; Draw ASCII art
;=============================
; Eventually will be LZ4 encoded to save room
; It's 7063 bytes of data unencoded
; A is which one to draw
; Decode it to 0x800 (text page 2) which we aren't using
; and we shouldn't have to worry about screen holes
draw_ascii_art:
sty TEMPY
asl
tay
dey
dey
lda ascii_art,Y
sta OUTL
lda ascii_art+1,Y
sta OUTH
; lda #<aperture
; sta OUTL
; lda #>aperture
; sta OUTH
ldy #0
ascii_loop:
lda (OUTL),Y
beq done_ascii
jsr COUT
; 16-bit increment
inc OUTL
bne alsb
inc OUTH
alsb:
jmp ascii_loop
done_ascii:
ldy TEMPY
rts
;============================
; Setup Word Bounds
;============================
word_bounds:
lda FORTYCOL
bne fortycol_word_bounds
eightycol_word_bounds:
; on 80 column, words go from 2,1 to 35,21
lda #2
sta WNDLFT
lda #35
sta WNDWDTH
lda #1
sta WNDTOP
lda #21
sta WNDBTM
rts
fortycol_word_bounds:
; on 40 column, words go from 1,0 to 35,4
lda #1
sta WNDLFT
lda #35
sta WNDWDTH
lda #0
sta WNDTOP
lda #4
sta WNDBTM
rts
;============================
; Setup Art Bounds
;============================
art_bounds:
lda FORTYCOL
bne fortycol_art_bounds
eightycol_art_bounds:
; on 80 column, art goes from 39,1 to 40,23 (????)
lda #2
sta WNDLFT
lda #35
sta WNDWDTH
lda #1
sta WNDTOP
lda #21
sta WNDBTM
rts
fortycol_art_bounds:
; on 40 column, art goes from 0,4 to 39,24
lda #2
sta WNDLFT
lda #35
sta WNDWDTH
lda #1
sta WNDTOP
lda #21
sta WNDBTM
rts
;=========
;routines
;=========
@ -524,6 +335,9 @@ fortycol_art_bounds:
.include "../asm_routines/gr_fast_clear.s"
.include "../asm_routines/lz4_decode.s"
.include "display_art.s"
.include "display_lyrics.s"
.include "interrupt_handler.s"
;=========

View File

@ -109,7 +109,7 @@ FORTYCOL EQU $9C
;COLOR2 EQU $E1
;MATCH EQU $E2
;XX EQU $E3
;YY EQU $E4
YY EQU $E4
;SHIPY EQU $E4
;YADD EQU $E5
;LOOP EQU $E6