mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 05:30:34 +00:00
added CX16 txt.setcc and swirl examples that use it
This commit is contained in:
parent
f45eabdd9e
commit
2b35498370
@ -268,20 +268,35 @@ asmsub print_w (word value @ AY) clobbers(A,Y) {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub setchr (ubyte column, ubyte row, ubyte char) {
|
; TODO implement the "missing" txtio subroutines
|
||||||
; ---- set char at the given position on the screen
|
|
||||||
; plot(column, row)
|
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
|
||||||
c64.CHROUT(char)
|
; ---- set char+color at the given position on the screen
|
||||||
; %asm {{
|
%asm {{
|
||||||
; phx
|
phx
|
||||||
; ldy column
|
lda column
|
||||||
; ldx row
|
asl a
|
||||||
; clc
|
tax
|
||||||
; jsr c64.PLOT
|
ldy row
|
||||||
; plx
|
lda charcolor
|
||||||
; lda char
|
and #$0f
|
||||||
; jmp c64.CHROUT
|
sta P8ZP_SCRATCH_B1
|
||||||
; }}
|
stz cx16.VERA_ADDR_H
|
||||||
|
stx cx16.VERA_ADDR_L
|
||||||
|
sty cx16.VERA_ADDR_M
|
||||||
|
lda char
|
||||||
|
sta cx16.VERA_DATA0
|
||||||
|
inx
|
||||||
|
stz cx16.VERA_ADDR_H
|
||||||
|
stx cx16.VERA_ADDR_L
|
||||||
|
sty cx16.VERA_ADDR_M
|
||||||
|
lda cx16.VERA_DATA0
|
||||||
|
and #$f0
|
||||||
|
ora P8ZP_SCRATCH_B1
|
||||||
|
sta cx16.VERA_DATA0
|
||||||
|
plx
|
||||||
|
rts
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) {
|
asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) {
|
||||||
|
27
examples/cx16/swirl-float.p8
Normal file
27
examples/cx16/swirl-float.p8
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
%import cx16textio
|
||||||
|
%import cx16flt
|
||||||
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
main {
|
||||||
|
|
||||||
|
const uword width = 80
|
||||||
|
const uword height = 60
|
||||||
|
|
||||||
|
struct Ball {
|
||||||
|
float t
|
||||||
|
ubyte color
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
|
||||||
|
Ball ball
|
||||||
|
|
||||||
|
repeat {
|
||||||
|
ubyte xx=(sin(ball.t) * width/2.1) + width/2.0 as ubyte
|
||||||
|
ubyte yy=(cos(ball.t*1.1356) * height/2.1) + height/2.0 as ubyte
|
||||||
|
txt.setcc(xx, yy, 81, ball.color)
|
||||||
|
ball.t += 0.05
|
||||||
|
ball.color++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
examples/cx16/swirl.p8
Normal file
30
examples/cx16/swirl.p8
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
%import cx16lib
|
||||||
|
%import cx16textio
|
||||||
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
main {
|
||||||
|
|
||||||
|
const uword width = 79
|
||||||
|
const uword height = 59
|
||||||
|
|
||||||
|
struct Ball {
|
||||||
|
uword anglex
|
||||||
|
uword angley
|
||||||
|
ubyte color
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
|
||||||
|
Ball ball
|
||||||
|
|
||||||
|
repeat {
|
||||||
|
ubyte x = msb(sin8u(msb(ball.anglex)) as uword * width)
|
||||||
|
ubyte y = msb(cos8u(msb(ball.angley)) as uword * height)
|
||||||
|
txt.setcc(x, y, 81, ball.color)
|
||||||
|
|
||||||
|
ball.anglex+=266
|
||||||
|
ball.angley+=215
|
||||||
|
ball.color++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,17 +6,21 @@ main {
|
|||||||
const uword width = 40
|
const uword width = 40
|
||||||
const uword height = 25
|
const uword height = 25
|
||||||
|
|
||||||
sub start() {
|
struct Ball {
|
||||||
|
|
||||||
float t
|
float t
|
||||||
ubyte color
|
ubyte color
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
|
||||||
|
Ball ball
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
ubyte xx=(sin(t) * width/2.2) + width/2.0 as ubyte
|
ubyte xx=(sin(ball.t) * width/2.1) + width/2.0 as ubyte
|
||||||
ubyte yy=(cos(t*1.1356) * height/2.2) + height/2.0 as ubyte
|
ubyte yy=(cos(ball.t*1.1356) * height/2.1) + height/2.0 as ubyte
|
||||||
txt.setcc(xx, yy, 81, color)
|
txt.setcc(xx, yy, 81, ball.color)
|
||||||
t += 0.08
|
ball.t += 0.08
|
||||||
color++
|
ball.color++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user