aboutsummaryrefslogtreecommitdiff
path: root/comptitle.s.in
diff options
context:
space:
mode:
Diffstat (limited to 'comptitle.s.in')
-rw-r--r--comptitle.s.in116
1 files changed, 116 insertions, 0 deletions
diff --git a/comptitle.s.in b/comptitle.s.in
new file mode 100644
index 0000000..7862b3d
--- /dev/null
+++ b/comptitle.s.in
@@ -0,0 +1,116 @@
+
+; cl65 -o comptitle.xex -t none comptitle.s
+
+; comptitle.s.in is used by titlecomp.pl, to generate comptitle.s.
+; __VARIABLE__ stuff is filled in by titlecomp.pl, q.v.
+; DON'T bother to edit comptitle.s (edit the .in file instead)!
+
+ .include "atari.inc"
+
+ ; size of uncompressed image, in bytes (but, needs to be
+ ; a multiple of $100).
+;imgsize = __SIZE__
+imgsize = $1700
+
+ ; these both need to be page-aligned. destination also needs
+ ; to be aligned on a 4K boundary.
+start = $2000
+destination = $9000
+
+srcptr = FR0
+dstptr = FR0+2
+pagecount = FR0+4
+tmp = FR0+5
+
+ .word $ffff
+ .word start
+ .word end-1
+
+ .org start
+
+compdata:
+ .incbin "comptitle.dat"
+
+; table runs __FIRSTCODE__ to __LASTCODE__
+table:
+ __TABLE__
+
+ ; decompression code starts here
+init:
+ lda #>imgsize
+ sta pagecount
+ lda #>compdata
+ sta srcptr+1
+ lda #>destination
+ sta dstptr+1
+ lda #0
+ sta srcptr
+ sta dstptr
+ tay
+
+copyloop:
+ lda (srcptr),y
+ bpl storebyte ; 0-127 always represent themselves
+ cmp #__LASTCODE__+1
+ bcs storebyte ; anything above the last code represents itself
+ sta tmp
+ sec
+ sbc #__FIRSTCODE__
+ bcc notcode ; anything below the 1st code represents itself
+ tax
+ lda table,x
+ beq notcode
+
+ ; got a zero-run code. A = number of bytes of zeroes to store.
+ jmp storezerorun
+
+notcode:
+ lda tmp
+
+storebyte:
+ sty tmp
+ ldy #0
+ sta (dstptr),y
+ jsr incdest
+ beq done
+nohi:
+ ldy tmp
+
+storedone:
+ iny
+ bne copyloop
+ inc srcptr+1
+ bne copyloop ; always branch (since srcptr never wraps around to 0)
+
+done:
+ rts
+
+storezerorun:
+ sty tmp
+ tay
+ dey
+ lda #0
+szloop:
+ sta (dstptr),y
+ jsr incdest
+ beq done
+nohi2:
+ dey
+ bpl szloop
+
+ ldy tmp
+ jmp storedone
+
+incdest:
+ inc dstptr
+ bne iddone
+ inc dstptr+1
+ dec pagecount
+iddone:
+ rts
+
+end:
+ .word INITAD
+ .word INITAD+1
+ .word init
+