57 lines
1.4 KiB
ArmAsm
57 lines
1.4 KiB
ArmAsm
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
|
|
|
;;Calculates values needed to draw a pixel on screen!
|
|
.proc pixel_calc
|
|
.include "pixel.inc"
|
|
|
|
;;FIND position to write byte_to_paint (btp_mem_pos)
|
|
;; + + + + + > X
|
|
;; +
|
|
;; +
|
|
;;\/
|
|
;; Y
|
|
|
|
;; The screen has a wierd memory to pixel maping!
|
|
;; Each line of 8 pixels is one byte
|
|
;; 8 consecutive bytes in memory makes up a chunk and are 'under each other' on the screen
|
|
;; the chunks are orderd from the left to the right and then looping downwards.
|
|
;; Therefore we have that: btp_mem_pos = big_x_offset + smal_y_offset + big_y_offset + bitmap_offset
|
|
|
|
;; We use a lookup-table for big_y_offset + bitmap_offset (see END.s)
|
|
;; (Y_pos / 8 floor)*2
|
|
LDA Y_pos
|
|
LSR A
|
|
LSR A
|
|
;; We need to remove the last digit if its still there
|
|
;; same as LSR ASR
|
|
AND #%11111110
|
|
TAX
|
|
;; big_y_offset + big_x_offset
|
|
CLC
|
|
;;A = big_x_offset
|
|
LDA #%11111000
|
|
AND X_pos
|
|
ADC big_y_offset, X
|
|
STA btp_mem_pos
|
|
LDA #$00
|
|
INX
|
|
ADC big_y_offset, X
|
|
STA btp_mem_pos + 1
|
|
|
|
;; + small_y_offset
|
|
LDA #%00000111 ; A = y (mod 8)
|
|
AND Y_pos ;; offset to add
|
|
TAY
|
|
|
|
calc_byte_to_paint: ;; aka small_x_offset
|
|
LDA X_pos
|
|
AND #%00000111
|
|
TAX
|
|
;;this is the same as: byte_to_paint = 2^X
|
|
LDA binary_factor, X;; (see END.s)
|
|
|
|
;; A = byte_to_paint (small_X_offset)
|
|
;; Y =small_y_offset
|
|
;; btp_mem_pos (bigg_X_offset + bigg_Y-offset)
|
|
RTS
|
|
.endproc
|