tests - Create routine for plotting a pixel at an (x, y) coordinate

This commit is contained in:
n loewen 2023-08-24 17:03:51 +01:00
parent 897749b108
commit f612e7582a
1 changed files with 69 additions and 0 deletions

69
test-programs/draw-xy.asm Normal file
View File

@ -0,0 +1,69 @@
; Routine for drawing at (x, y) coordinates
#zeroflag 1
; *** Set your desired (x, y) here: ***
#input_x 1
#input_y 1
; Set up some handy shortcuts
#x $FA
#y $FB
#return_addr_ptr $FE
; Main:
LDA #input_x
STO #x
LDA #input_y
STO #y
LDA * 6 ; acc = current address + 6 (LDA, STO, JMP = 6)
STO #return_addr_ptr
JMP @getxy
LDA $FF
STO ($FD)
END
;; Convert a pair of (x, y) coords
;; to the address of a pixel on the display
;;
;; Call with:
;; - x in #x
;; - y in #y
;; - return address in #return_addr_ptr
;;
;; Returns: pixel address in $FD
@getxy
#gxy_px $FD
; stash x...
LDA (#x)
STO #gxy_px
; check if this is row 0...
LDA (#y)
FHP #zeroflag
JMP @getxy_loop
JMP (#return_addr_ptr) ; if row 0, we're done
@getxy_loop
LDA (#gxy_px)
ADD 5 ; add 5 to get to the next row
STO #gxy_px
LDA (#y) ; decrement y (it's acting as a loop counter)...
SUB 1
STO #y
FHP #zeroflag
JMP @getxy_loop
JMP (#return_addr_ptr)
;; Main variables:
;; F8
;; F9
;; FA - x coord
;; FB - y coord
;; FC - gxy temp
;; FD - gxy temp
;; FE - Return address for subroutine