Add more skeleton code for future triangle drawing
This commit is contained in:
parent
c27e79efa6
commit
737ebbbe51
8 changed files with 67 additions and 34 deletions
|
@ -9,9 +9,9 @@
|
||||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
||||||
|
|
||||||
.proc line_down
|
.proc line_down
|
||||||
|
|
||||||
.include "line.inc"; Defines memory positions, ex X_pos
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
|
|
||||||
|
|
||||||
;;We need to clear this memory
|
;;We need to clear this memory
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA V +1
|
STA V +1
|
||||||
|
@ -42,7 +42,6 @@
|
||||||
Mov_16 D, D + 1, dy_2, dy_2 +1
|
Mov_16 D, D + 1, dy_2, dy_2 +1
|
||||||
Add_16 D, D + 1, #$ff, #$01, !
|
Add_16 D, D + 1, #$ff, #$01, !
|
||||||
Sub_16 D, D + 1, dx, #$00
|
Sub_16 D, D + 1, dx, #$00
|
||||||
|
|
||||||
selfmod:
|
selfmod:
|
||||||
;; Self modifying code. Makes LDA and SBC instructions each take 1 cycle less.
|
;; Self modifying code. Makes LDA and SBC instructions each take 1 cycle less.
|
||||||
;; You can remove this if you run the loop without # at dy_2 and V.
|
;; You can remove this if you run the loop without # at dy_2 and V.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
;; Program for testing of line-drawing. It draws a bunch of lines
|
;; Program for testing of line-drawing. It draws a bunch of lines
|
||||||
;;Start line-timer-here
|
;;Start line-timer-here
|
||||||
.include "line.inc"
|
.include "line.inc"
|
||||||
|
|
||||||
Y_pos_ = $0D
|
Y_pos_ = $0D
|
||||||
X_pos_ = $0E
|
X_pos_ = $0E
|
||||||
Y_end_ = $10
|
Y_end_ = $10
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
jmp @loop
|
jmp @loop
|
||||||
end__:
|
end__:
|
||||||
|
|
||||||
|
|
||||||
;; Full anfle test
|
;; Full anfle test
|
||||||
@loop:
|
@loop:
|
||||||
LDA Y_pos_
|
LDA Y_pos_
|
||||||
|
|
6
wip-hugo/routines/triangle/lower_triangle.s
Normal file
6
wip-hugo/routines/triangle/lower_triangle.s
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
|
;; This is a help program for triangle.s to draw the lower triangle
|
||||||
|
.scope lower_triangle
|
||||||
|
NOP
|
||||||
|
.endscope
|
|
@ -1,3 +1,5 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;;The triangles 3 corner-positions, they may be in any given order.
|
;;The triangles 3 corner-positions, they may be in any given order.
|
||||||
A_X = $EA
|
A_X = $EA
|
||||||
A_Y = $E9
|
A_Y = $E9
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
.proc triangle
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;; Subroutine for drawing a filld triangle.
|
;; Subroutine for drawing a filld triangle.
|
||||||
;; It takes in values from A_X, A_Y, B_X, B_Y C_X, C_Y, see triangle.inc
|
.proc triangle
|
||||||
|
;; It takes in values from A_X, A_Y, B_X, B_Y C_X, C_Y, see triangle.inc
|
||||||
.include "triangle.inc"
|
.include "triangle.inc"
|
||||||
|
|
||||||
;; Algorithm
|
;; Algorithm
|
||||||
|
@ -19,7 +21,7 @@
|
||||||
;; * AB for differense betwean A and B
|
;; * AB for differense betwean A and B
|
||||||
;; * BC for differense betwean B and C
|
;; * BC for differense betwean B and C
|
||||||
|
|
||||||
;;AB
|
;;AB
|
||||||
SEC
|
SEC
|
||||||
LDA B_Y
|
LDA B_Y
|
||||||
SBC A_Y
|
SBC A_Y
|
||||||
|
@ -38,12 +40,12 @@ AB_overflow:
|
||||||
STX A_X
|
STX A_X
|
||||||
STY B_X
|
STY B_X
|
||||||
AB_overflow_end:
|
AB_overflow_end:
|
||||||
;;BC
|
;;BC
|
||||||
SEC
|
SEC
|
||||||
LDA C_Y
|
LDA C_Y
|
||||||
SBC B_Y
|
SBC B_Y
|
||||||
STA BC
|
STA BC
|
||||||
BCC BC_overflow_end
|
BCC BC_overflow_end
|
||||||
;; B_Y > C_Y
|
;; B_Y > C_Y
|
||||||
BC_overflow:
|
BC_overflow:
|
||||||
EOR #$ff ; Fix byte underflow
|
EOR #$ff ; Fix byte underflow
|
||||||
|
@ -61,20 +63,9 @@ BC_overflow:
|
||||||
BC_overflow_end:
|
BC_overflow_end:
|
||||||
|
|
||||||
draw_upper_triangle:
|
draw_upper_triangle:
|
||||||
# This triangle has 10 posibol cases, see table bellow
|
.include "upper_triangle.s"
|
||||||
# ----------------------------------------------------
|
draw_lower_triangle:
|
||||||
# | name left_side right_side |
|
;;This has the same cases as upper triangle
|
||||||
# ----------------------------------------------------
|
.include "lower_triangle.s"
|
||||||
# | RR right-sloaping-steep right-sloaping-steep|
|
RTS
|
||||||
# | rR right-sloaping right-sloaping-steep|
|
|
||||||
# | lR left-sloaping right-sloaping-steep|
|
|
||||||
# | LR left-sloaping-steep right-sloaping-steep|
|
|
||||||
# | rr right-sloaping right-sloaping |
|
|
||||||
# | lr left-sloaping right-sloaping |
|
|
||||||
# | Lr left-sloaping-steep right-sloaping |
|
|
||||||
# | ll left-sloaping left-sloaping |
|
|
||||||
# | Ll left-sloaping-sleep left-sloaping |
|
|
||||||
# | LL left-sloaping-sleep left-sloaping-sleep |
|
|
||||||
# ----------------------------------------------------
|
|
||||||
RTS
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
.scope triangle_test
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;; Test program that tries to draw a triangle
|
;; Test program that tries to draw a triangle
|
||||||
|
.scope triangle_test
|
||||||
.include "triangle.inc"
|
.include "triangle.inc"
|
||||||
LDA #$33
|
LDA #$33
|
||||||
STA A_X
|
STA A_X
|
||||||
|
@ -22,17 +24,17 @@ edges:
|
||||||
;;; A -- B
|
;;; A -- B
|
||||||
Mov_16 X_pos, Y_pos, A_X, A_Y
|
Mov_16 X_pos, Y_pos, A_X, A_Y
|
||||||
Mov_16 X_end, Y_end, B_X, B_Y
|
Mov_16 X_end, Y_end, B_X, B_Y
|
||||||
jsr line
|
JSR line
|
||||||
;;; A -- C
|
;;; A -- C
|
||||||
Mov_16 X_pos, Y_pos, A_X, A_Y
|
Mov_16 X_pos, Y_pos, A_X, A_Y
|
||||||
Mov_16 X_end, Y_end, C_X, C_Y
|
Mov_16 X_end, Y_end, C_X, C_Y
|
||||||
jsr line
|
JSR line
|
||||||
;;; B -- C
|
;;; B -- C
|
||||||
Mov_16 X_pos, Y_pos, C_X, C_Y
|
Mov_16 X_pos, Y_pos, C_X, C_Y
|
||||||
Mov_16 X_end, Y_end, B_X, B_Y
|
Mov_16 X_end, Y_end, B_X, B_Y
|
||||||
jsr line
|
JSR line
|
||||||
skip_edges:
|
skip_edges:
|
||||||
;; lets draw the example triangle
|
;; lets draw the example triangle
|
||||||
jsr triangle
|
JSR triangle
|
||||||
jmp exit
|
JMP exit
|
||||||
.endscope
|
.endscope
|
||||||
|
|
31
wip-hugo/routines/triangle/upper_triangle.s
Normal file
31
wip-hugo/routines/triangle/upper_triangle.s
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
;; Test program that tries to draw a triangle
|
||||||
|
|
||||||
|
;; This is a help program for triangle.s to draw the upper triangle
|
||||||
|
|
||||||
|
;; We know that (se triangle.inc)
|
||||||
|
;; (i) A is at the highest point
|
||||||
|
;; (ii) B is at the middle point
|
||||||
|
;; (iii) C is at the lowest point
|
||||||
|
|
||||||
|
;; This triangle has 10 posibol cases, see table bellow
|
||||||
|
;; ----------------------------------------------------
|
||||||
|
;; | name left_side right_side |
|
||||||
|
;; ----------------------------------------------------
|
||||||
|
;; | RR right-sloaping-steep right-sloaping-steep|
|
||||||
|
;; | rR right-sloaping right-sloaping-steep|
|
||||||
|
;; | lR left-sloaping right-sloaping-steep|
|
||||||
|
;; | LR left-sloaping-steep right-sloaping-steep|
|
||||||
|
;; | rr right-sloaping right-sloaping |
|
||||||
|
;; | lr left-sloaping right-sloaping |
|
||||||
|
;; | Lr left-sloaping-steep right-sloaping |
|
||||||
|
;; | ll left-sloaping left-sloaping |
|
||||||
|
;; | Ll left-sloaping-sleep left-sloaping |
|
||||||
|
;; | LL left-sloaping-sleep left-sloaping-sleep |
|
||||||
|
;; ----------------------------------------------------
|
||||||
|
|
||||||
|
.scope upper_triangle
|
||||||
|
LDA #$00
|
||||||
|
;; Lets for the sake of it say its a lr triangle
|
||||||
|
;; we need to compute V_l, V_r, dy_2l, dy_2_r, D_l, and D_r
|
||||||
|
|
||||||
|
.endscope
|
|
@ -10,7 +10,7 @@
|
||||||
;.include "routines/memory/memcpy_test.s"
|
;.include "routines/memory/memcpy_test.s"
|
||||||
.include "routines/triangle/triangle_test.s"
|
.include "routines/triangle/triangle_test.s"
|
||||||
exit:
|
exit:
|
||||||
jmp exit
|
JMP exit
|
||||||
.include "routines/line/line.s"
|
.include "routines/line/line.s"
|
||||||
.include "routines/triangle/triangle.s"
|
.include "routines/triangle/triangle.s"
|
||||||
.include "routines/memory/pixel_draw.s"
|
.include "routines/memory/pixel_draw.s"
|
||||||
|
|
Loading…
Add table
Reference in a new issue