;;; -*- 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" ;; Lets clear some memory for later LDA #$00 STA btp_mem_pos + 1 calc_byte_to_paint: ;; X = X_pos (mod 8) 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 ;;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 (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 LSR A ASL A TAX LDA big_y_offset, X STA btp_mem_pos INX LDA big_y_offset,X STA btp_mem_pos + 1 ;; btp_mem_pos = big_x_offset LDA #%11111000 AND X_pos Add_16 btp_mem_pos, btp_mem_pos +1, A, #$00 ;; + smal_y_offset LDA #%00000111 ; A = y (mod 8) AND Y_pos ;; offset to add TAY Add_16 btp_mem_pos, btp_mem_pos + 1, #Bitmap, ! ;;Let draw some stuff LDA byte_to_paint ;; note that both bytes are used! ORA (btp_mem_pos), Y STA (btp_mem_pos), Y RTS .endproc