mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
tweak cx16 mandelbrots
This commit is contained in:
parent
0f9ce319d4
commit
e61818f194
@ -16,7 +16,7 @@ graphics {
|
||||
|
||||
sub clear_screen(ubyte pixelcolor, ubyte bgcolor) {
|
||||
memset(bitmap_address, 320*200/8, 0)
|
||||
txt.clear_screen(pixelcolor << 4 | bgcolor, 0)
|
||||
txt.fill_screen(pixelcolor << 4 | bgcolor, 0)
|
||||
}
|
||||
|
||||
sub line(uword @zp x1, ubyte @zp y1, uword @zp x2, ubyte @zp y2) {
|
||||
@ -218,7 +218,7 @@ _ormask .byte 128, 64, 32, 16, 8, 4, 2, 1
|
||||
; note: this can be even faster if we also have a 256 byte x-lookup table, but hey.
|
||||
; see http://codebase64.org/doku.php?id=base:various_techniques_to_calculate_adresses_fast_common_screen_formats_for_pixel_graphics
|
||||
; the y lookup tables encodes this formula: bitmap_address + 320*(py>>3) + (py & 7) (y from 0..199)
|
||||
; TODO can we use an assembly function for this to calc this?
|
||||
; TODO can we use an assembler function for this to calc this at assembly-time?
|
||||
_y_lookup_hi
|
||||
.byte $20, $20, $20, $20, $20, $20, $20, $20, $21, $21, $21, $21, $21, $21, $21, $21
|
||||
.byte $22, $22, $22, $22, $22, $22, $22, $22, $23, $23, $23, $23, $23, $23, $23, $23
|
||||
|
@ -11,8 +11,16 @@
|
||||
|
||||
txt {
|
||||
|
||||
asmsub clear_screen (ubyte char @ A, ubyte charcolor @ Y) clobbers(A) {
|
||||
; ---- clear the character screen with the given fill character and character color.
|
||||
asmsub clear_screen() {
|
||||
%asm {{
|
||||
lda #' '
|
||||
jmp clear_screenchars
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
asmsub fill_screen (ubyte char @ A, ubyte charcolor @ Y) clobbers(A) {
|
||||
; ---- fill the character screen with the given fill character and character color.
|
||||
; (assumes screen and color matrix are at their default addresses)
|
||||
|
||||
%asm {{
|
||||
|
@ -11,11 +11,26 @@
|
||||
|
||||
txt {
|
||||
|
||||
asmsub clear_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
|
||||
sub clear_screen() {
|
||||
c64.CHROUT(147) ; clear screen (spaces)
|
||||
}
|
||||
|
||||
|
||||
asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
|
||||
; ---- clear the character screen with the given fill character and character color.
|
||||
|
||||
%asm {{
|
||||
brk ; TODO
|
||||
pha
|
||||
tya
|
||||
and #$0f
|
||||
lda txt.color_to_charcode,y
|
||||
jsr c64.CHROUT
|
||||
pla
|
||||
cmp #' '
|
||||
bne +
|
||||
lda #147 ; clear screen
|
||||
jmp c64.CHROUT
|
||||
+ brk ; TODO fill screen with another character than space....
|
||||
}}
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,26 @@
|
||||
%import cx16textio
|
||||
%import cx16flt
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
const uword width = 256
|
||||
const uword height = 200
|
||||
const ubyte max_iter = 16
|
||||
const ubyte max_iter = 32
|
||||
|
||||
sub start() {
|
||||
initialize()
|
||||
mandel()
|
||||
repeat {
|
||||
; do nothing
|
||||
}
|
||||
}
|
||||
|
||||
void cx16.screen_set_mode($80)
|
||||
cx16.r0=0
|
||||
cx16.FB_init()
|
||||
|
||||
sub mandel() {
|
||||
ubyte pixelx
|
||||
ubyte pixely
|
||||
|
||||
for pixely in 0 to height-1 {
|
||||
float yy = (pixely as float)/0.4/height - 1.0
|
||||
float yy = (pixely as float)/0.35/height - 1.35
|
||||
|
||||
cx16.r0 = 0
|
||||
cx16.r1 = pixely
|
||||
@ -40,6 +44,44 @@ main {
|
||||
}
|
||||
cx16.FB_set_pixel(max_iter-iter)
|
||||
}
|
||||
|
||||
print_time()
|
||||
}
|
||||
}
|
||||
|
||||
sub initialize() {
|
||||
void cx16.screen_set_mode($80)
|
||||
|
||||
txt.plot(32, 5)
|
||||
txt.print("256*200")
|
||||
txt.plot(32, 6)
|
||||
txt.print("mandel-")
|
||||
txt.plot(33, 7)
|
||||
txt.print("brot")
|
||||
txt.plot(32, 9)
|
||||
txt.print("floats")
|
||||
txt.plot(32, 10)
|
||||
txt.print("32 iter")
|
||||
|
||||
cx16.r0 = 0
|
||||
cx16.r1 = 0
|
||||
cx16.r2 = 0
|
||||
cx16.r3 = 0
|
||||
cx16.clock_set_date_time()
|
||||
|
||||
cx16.r0=0
|
||||
cx16.FB_init()
|
||||
}
|
||||
|
||||
sub print_time() {
|
||||
cx16.clock_get_date_time()
|
||||
txt.plot(33, 12)
|
||||
if lsb(cx16.r2) < 10
|
||||
c64.CHROUT('0')
|
||||
txt.print_ub(lsb(cx16.r2))
|
||||
c64.CHROUT(':')
|
||||
if msb(cx16.r2) < 10
|
||||
c64.CHROUT('0')
|
||||
txt.print_ub(msb(cx16.r2))
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ main {
|
||||
ubyte pixely
|
||||
|
||||
for pixely in 0 to height-1 {
|
||||
float yy = (pixely as float)/0.4/height - 1.0
|
||||
float yy = (pixely as float)/0.40/height - 1.3
|
||||
|
||||
for pixelx in 0 to width-1 {
|
||||
float xx = (pixelx as float)/0.3/width - 2.2
|
||||
float xx = (pixelx as float)/0.32/width - 2.2
|
||||
|
||||
float xsquared = 0.0
|
||||
float ysquared = 0.0
|
||||
|
@ -16,13 +16,13 @@ main {
|
||||
txt.print("enter for disc:")
|
||||
void c64.CHRIN()
|
||||
c64.CHROUT('\n')
|
||||
txt.clear_screen(' ', 1)
|
||||
txt.clear_screen()
|
||||
disc(20, 12, 12)
|
||||
|
||||
txt.print("enter for lines:")
|
||||
void c64.CHRIN()
|
||||
c64.CHROUT('\n')
|
||||
txt.clear_screen(' ', 1)
|
||||
txt.clear_screen()
|
||||
|
||||
line(1, 10, 38, 24)
|
||||
line(1, 20, 38, 2)
|
||||
@ -32,7 +32,7 @@ main {
|
||||
txt.print("enter for rectangles:")
|
||||
void c64.CHRIN()
|
||||
c64.CHROUT('\n')
|
||||
txt.clear_screen(' ', 1)
|
||||
txt.clear_screen()
|
||||
|
||||
rect(4, 8, 37, 23, false)
|
||||
rect(20, 12, 30, 20, true)
|
||||
|
Loading…
Reference in New Issue
Block a user