Programowanie: Rysowanie punktu

From Atariki

Jump to: navigation, search

Plot dla trybu lowres (Graphics 15) 160x192:

COLOR = 1  ;kolor z zakresu 0,1,2,3

  org $80
adr .ds 2

;Y = y, X = x
plot:
  lda lnadl,y
  sta adr
  lda lnadh,y
  sta adr+1

  ldy byteoff,x

  lda (adr),y
  and bytemask,x
  ora bytepxl,x
  sta (adr),y
  rts

lnadl:
:192 .byte <(screen+40*#)
lnadh:
:192 .byte >(screen+40*#)
byteoff:
:160 .byte #/4
bytemask:
:160 .byte ~(%11 << (6 - ((# & %11) * 2)))
bytepxl:
:160 .byte COLOR << (6 - ((# & %11) * 2))

Plot dla trybu hires (Graphics 8) 320x192:

COLOR = 1  ;kolor z zakresu 0,1

  org $80
adr .ds 2

;Y = y, X = <x, C = >x
plot:
  lda lnadl,y
  sta adr
  lda lnadh,y
  sta adr+1

  bcs ?1xx

?0xx:
  ldy byteoff,x
  lda (adr),y
  and bytemask,x
  ora bytepxl,x
  sta (adr),y
  rts

?1xx:
  ldy byteoff+$100,x
  lda (adr),y
  and bytemask,x
  ora bytepxl,x
  sta (adr),y
  rts

lnadl:
:192 .byte <(screen+40*#)
lnadh:
:192 .byte >(screen+40*#)
byteoff:
:320 .byte #/8
bytemask:
:256 .byte ~(1 << (7 - (# & %111)))
bytepxl:
:256 .byte COLOR << (7 - (# & %111))
Personal tools