185 lines
2.7 KiB
ArmAsm
Raw Normal View History

2022-03-14 00:26:11 -04:00
;=================================
; Simple Horizontal LINE
;=================================
; line from (x,a) to (x+y,a)
; todo: use Carry to say if X>255
hgr_hlin:
; get ROW into (GBASL)
sty xrun_save
stx x1_save
2022-03-14 01:02:58 -04:00
; X1 already in X
; Y1 already in A ; Y1 into A
2022-03-14 00:26:11 -04:00
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
; important part is row is in GBASL/GBASH
; also shifts color for us
; Y is already the RX1/7
; check if narrow corner case where begin and end same block
2022-03-14 01:02:58 -04:00
; if RX%7 + XRUN < 7
2022-03-14 00:26:11 -04:00
ldx x1_save
lda mod7_table,X
clc
adc xrun_save
cmp #7
bcs not_same_block
same_block:
2022-03-14 01:02:58 -04:00
; want to use MASK of left_mask (MOD7) ANDed with ~left_mask (MOD7+XRUN)
2022-03-14 00:26:11 -04:00
; 4+3
; 0000 CCCC 0000 1111
; 0000 000C 0000 0001
; 4000 = 80 80
; 4400 = 81 81
; 4800 = 83 83
; 4C00 = 87 87
; 5000 = 8F 8F
; 5400 = 9F 9F
; 5800 = BF BF
;----
; 5C00 = FF FF
2022-03-14 01:02:58 -04:00
; 4080 = ff 81 FF 81
; 4480 = ff 83
; 4880 = ff 87
2022-03-14 00:26:11 -04:00
lda mod7_table,X ; get x1%7
tax ; put in X
2022-03-14 01:02:58 -04:00
lda left_masks,X ; get left mask
sta same_block_mask_smc+1
2022-03-14 00:26:11 -04:00
txa ; x1%7
clc
adc xrun_save ; (x1%7)+xrun
tax
2022-03-14 01:02:58 -04:00
lda left_masks,X ; get left mask
2022-03-14 00:26:11 -04:00
eor #$7f
2022-03-14 01:02:58 -04:00
and same_block_mask_smc+1
sta same_block_mask_smc+1
2022-03-14 00:26:11 -04:00
lda (GBASL),Y
eor HGR_BITS
2022-03-14 01:02:58 -04:00
same_block_mask_smc:
and #$dd
2022-03-14 00:26:11 -04:00
eor (GBASL),Y
sta (GBASL),Y
rts
not_same_block:
; see if not starting on boundary
2022-03-14 01:02:58 -04:00
; X still has X1 in it
2022-03-14 00:26:11 -04:00
lda mod7_table,X
beq draw_run
; handle not full left border
handle_ragged_left:
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
eor (GBASL),Y
sta (GBASL),Y
iny ; move to next
; adjust RUN length by 7- mod7
txa ; load mod7
eor #$ff
sec
adc #7
eor #$ff
sec
adc xrun_save
sta xrun_save
jsr shift_colors
; draw common
draw_run:
lda xrun_save
cmp #7
bcc draw_right ; blt
lda HGR_BITS ; get color
sta (GBASL),Y ; store out
iny ; move to next block
jsr shift_colors
lda xrun_save ; take 7 off the run
sec
sbc #7
sta xrun_save
jmp draw_run
; draw rightmost
draw_right:
2022-03-14 01:02:58 -04:00
beq done_hgr_hlin
2022-03-14 00:26:11 -04:00
; see if not starting on boundary
ldx xrun_save
tax
lda (GBASL),Y
eor HGR_BITS
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
2022-03-14 01:02:58 -04:00
done_hgr_hlin:
2022-03-14 00:26:11 -04:00
rts
x1_save: .byte $00
xrun_save: .byte $00
2022-03-14 01:02:58 -04:00
right_masks:
.byte $80,$81,$83,$87, $8F,$9F,$BF
2022-03-14 00:26:11 -04:00
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
2022-03-14 01:02:58 -04:00
2022-03-14 00:26:11 -04:00
;==========================
; shift colors
;==========================
; 00000000 and 10000000 => no change (black)
; 01111111 and 11111111 => no change? (white)
; 01010101 => invert 00101010
shift_colors:
lda HGR_BITS
asl
cmp #$C0
bpl done_shift_colors
lda HGR_BITS
eor #$7f
sta HGR_BITS
done_shift_colors:
rts
;==========================
; set color
;==========================
; color in X
set_hcolor:
lda COLORTBL,X
sta HGR_COLOR
rts