Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .word $1000
- *=$1000
- dp = $c0
- sp = $c2
- cs = $c4
- sei
- lda #<data
- sta sp
- lda #>data
- sta sp+1
- lda #<$0400
- sta dp
- lda #>$0400
- sta dp+1
- jsr decrunch
- jmp *
- decrunch_done:
- rts
- literal_run
- literal_loop
- iny
- lda (sp),y
- sta (dp),y
- dex
- bmi literal_loop
- tya
- pha
- clc
- increase_dp_by_a_and_sp_by_tos_plus_one
- adc dp
- sta dp
- bcc l1
- inc dp+1
- l1
- pla
- update_sp
- sec
- adc sp
- sta sp
- bcc l2
- inc sp+1
- l2
- decrunch
- next_command
- ldy #0
- lda (sp),y
- tax
- beq decrunch_done
- asl
- bcc far_copy
- bpl literal_run
- near_copy
- ldx #$07 ; clear high byte of -ve offset. Also ensures copy_loop doesn't loop.
- .byt $f0 ; beq (not taken) to skip over the iny
- far_copy
- iny
- ; carry is set for near_copy, clear for far_copy
- lda (sp),y ;fetch second byte (or for near copy, refetch first). This is low 8 bits of offset.
- adc dp
- sta cs
- txa
- ora #$f8
- adc dp+1
- sta cs+1
- tya
- pha ; save opcode length to stack
- ldy#1
- lda (cs),y
- sta (dp),y
- ;sec ;to replace sbx
- ;sec
- copy_loop:
- iny
- lda (cs),y
- sta (dp),y
- txa ; spend an extra 2 cycles per byte here to save 10 in the bitfield extraction. A win on average
- ;sbx#8
- sbc #8
- txa
- bpl copy_loop
- tya
- bcc increase_dp_by_a_and_sp_by_tos_plus_one ; always taken.
- edecrunch
- rts
- data
- .bin 0,0,"screen.tuc"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement