;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;Screen print. Draws a pixel at a specified position. .proc pixel_draw; user-procedure :clobbers (A X Y) :clobbers-arguments 0 .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) STA byte_to_paint ;; should be removed, here for other code! draw: ;;Let draw some stuff ORA (btp_mem_pos), Y STA (btp_mem_pos), Y RTS .endproc