mirror of
https://github.com/irmen/prog8.git
synced 2024-10-17 10:24:55 +00:00
added gfx2.pget(x,y) to get the pixel color value
This commit is contained in:
parent
38efaae7b2
commit
7315b581ce
@ -366,7 +366,7 @@ _done
|
|||||||
position2(x,y,true)
|
position2(x,y,true)
|
||||||
set_both_strides(13) ; 160 increment = 1 line in 640 px 4c mode
|
set_both_strides(13) ; 160 increment = 1 line in 640 px 4c mode
|
||||||
color &= 3
|
color &= 3
|
||||||
color <<= gfx2.plot.shift4c[lsb(x) & 3]
|
color <<= gfx2.plot.shift4c[lsb(x) & 3] ; TODO with lookup table
|
||||||
ubyte @shared mask = gfx2.plot.mask4c[lsb(x) & 3]
|
ubyte @shared mask = gfx2.plot.mask4c[lsb(x) & 3]
|
||||||
repeat lheight {
|
repeat lheight {
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -561,7 +561,11 @@ _done
|
|||||||
and #1
|
and #1
|
||||||
}}
|
}}
|
||||||
if_nz {
|
if_nz {
|
||||||
cx16.r0L = lsb(x) & 7 ; xbits
|
%asm {{
|
||||||
|
lda x
|
||||||
|
and #7
|
||||||
|
pha ; xbits
|
||||||
|
}}
|
||||||
x /= 8
|
x /= 8
|
||||||
x += y*(320/8)
|
x += y*(320/8)
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -571,7 +575,7 @@ _done
|
|||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
lda x
|
lda x
|
||||||
sta cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L
|
||||||
ldy cx16.r0L ; xbits
|
ply ; xbits
|
||||||
lda bits,y
|
lda bits,y
|
||||||
ldy color
|
ldy color
|
||||||
beq +
|
beq +
|
||||||
@ -608,7 +612,11 @@ _done
|
|||||||
and #1
|
and #1
|
||||||
}}
|
}}
|
||||||
if_nz {
|
if_nz {
|
||||||
cx16.r0L = lsb(x) & 7 ; xbits
|
%asm {{
|
||||||
|
lda x
|
||||||
|
and #7
|
||||||
|
pha ; xbits
|
||||||
|
}}
|
||||||
x /= 8
|
x /= 8
|
||||||
x += y*(640/8)
|
x += y*(640/8)
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -618,7 +626,7 @@ _done
|
|||||||
sta cx16.VERA_ADDR_M
|
sta cx16.VERA_ADDR_M
|
||||||
lda x
|
lda x
|
||||||
sta cx16.VERA_ADDR_L
|
sta cx16.VERA_ADDR_L
|
||||||
ldy cx16.r0L ; xbits
|
ply ; xbits
|
||||||
lda bits,y
|
lda bits,y
|
||||||
ldy color
|
ldy color
|
||||||
beq +
|
beq +
|
||||||
@ -635,7 +643,7 @@ _done
|
|||||||
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
|
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
|
||||||
cx16.r2L = lsb(x) & 3 ; xbits
|
cx16.r2L = lsb(x) & 3 ; xbits
|
||||||
color &= 3
|
color &= 3
|
||||||
color <<= shift4c[cx16.r2L]
|
color <<= shift4c[cx16.r2L] ; TODO with lookup table
|
||||||
%asm {{
|
%asm {{
|
||||||
stz cx16.VERA_CTRL
|
stz cx16.VERA_CTRL
|
||||||
lda cx16.r1L
|
lda cx16.r1L
|
||||||
@ -654,6 +662,93 @@ _done
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub pget(uword @zp x, uword y) -> ubyte {
|
||||||
|
when active_mode {
|
||||||
|
1 -> {
|
||||||
|
; lores monochrome
|
||||||
|
%asm {{
|
||||||
|
lda x
|
||||||
|
and #7
|
||||||
|
pha ; xbits
|
||||||
|
}}
|
||||||
|
x /= 8
|
||||||
|
x += y*(320/8)
|
||||||
|
%asm {{
|
||||||
|
stz cx16.VERA_CTRL
|
||||||
|
stz cx16.VERA_ADDR_H
|
||||||
|
lda x+1
|
||||||
|
sta cx16.VERA_ADDR_M
|
||||||
|
lda x
|
||||||
|
sta cx16.VERA_ADDR_L
|
||||||
|
ply ; xbits
|
||||||
|
lda plot.bits,y
|
||||||
|
and cx16.VERA_DATA0
|
||||||
|
beq +
|
||||||
|
lda #1
|
||||||
|
+
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
; TODO mode 2 and 3
|
||||||
|
4 -> {
|
||||||
|
; lores 256c
|
||||||
|
void addr_mul_24_for_lores_256c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
|
||||||
|
%asm {{
|
||||||
|
stz cx16.VERA_CTRL
|
||||||
|
lda cx16.r1
|
||||||
|
sta cx16.VERA_ADDR_H
|
||||||
|
lda cx16.r0+1
|
||||||
|
sta cx16.VERA_ADDR_M
|
||||||
|
lda cx16.r0
|
||||||
|
sta cx16.VERA_ADDR_L
|
||||||
|
lda cx16.VERA_DATA0
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
5 -> {
|
||||||
|
; hires monochrome
|
||||||
|
%asm {{
|
||||||
|
lda x
|
||||||
|
and #7
|
||||||
|
pha ; xbits
|
||||||
|
}}
|
||||||
|
x /= 8
|
||||||
|
x += y*(640/8)
|
||||||
|
%asm {{
|
||||||
|
stz cx16.VERA_CTRL
|
||||||
|
stz cx16.VERA_ADDR_H
|
||||||
|
lda x+1
|
||||||
|
sta cx16.VERA_ADDR_M
|
||||||
|
lda x
|
||||||
|
sta cx16.VERA_ADDR_L
|
||||||
|
ply ; xbits
|
||||||
|
lda plot.bits,y
|
||||||
|
and cx16.VERA_DATA0
|
||||||
|
beq +
|
||||||
|
lda #1
|
||||||
|
+
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
6 -> {
|
||||||
|
; hires 4c
|
||||||
|
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
|
||||||
|
%asm {{
|
||||||
|
stz cx16.VERA_CTRL
|
||||||
|
lda cx16.r1L
|
||||||
|
sta cx16.VERA_ADDR_H
|
||||||
|
lda cx16.r0H
|
||||||
|
sta cx16.VERA_ADDR_M
|
||||||
|
lda cx16.r0L
|
||||||
|
sta cx16.VERA_ADDR_L
|
||||||
|
lda cx16.VERA_DATA0
|
||||||
|
sta cx16.r0L
|
||||||
|
}}
|
||||||
|
cx16.r1L = lsb(x) & 3
|
||||||
|
cx16.r0L >>= gfx2.plot.shift4c[cx16.r1L] ; TODO with lookup table
|
||||||
|
return cx16.r0L & 3
|
||||||
|
}
|
||||||
|
else -> return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub position(uword @zp x, uword y) {
|
sub position(uword @zp x, uword y) {
|
||||||
ubyte bank
|
ubyte bank
|
||||||
when active_mode {
|
when active_mode {
|
||||||
|
@ -347,7 +347,7 @@ Full-screen multicolor bitmap graphics routines, available on the Cx16 machine o
|
|||||||
|
|
||||||
- multiple full-screen resolutions: 640 * 480 monochrome, and 320 * 240 monochrome and 256 colors
|
- multiple full-screen resolutions: 640 * 480 monochrome, and 320 * 240 monochrome and 256 colors
|
||||||
- clearing screen, switching screen mode, also back to text mode is possible.
|
- clearing screen, switching screen mode, also back to text mode is possible.
|
||||||
- drawing individual pixels
|
- drawing and reading individual pixels
|
||||||
- drawing lines, rectangles, filled rectangles, circles, discs
|
- drawing lines, rectangles, filled rectangles, circles, discs
|
||||||
- drawing text inside the bitmap
|
- drawing text inside the bitmap
|
||||||
- in monochrome mode, it's possible to use a stippled drawing pattern to simulate a shade of gray.
|
- in monochrome mode, it's possible to use a stippled drawing pattern to simulate a shade of gray.
|
||||||
|
@ -3,7 +3,7 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- add a pget() to gfx2 to get the pixel color value
|
- fix cx16/kefrenbars.p8
|
||||||
- ir: write addresses as hex into p8ir file
|
- ir: write addresses as hex into p8ir file
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1,39 +1,28 @@
|
|||||||
|
%import gfx2
|
||||||
%import textio
|
%import textio
|
||||||
%import floats
|
|
||||||
%import string
|
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
sub start() {
|
||||||
str name1 = "abc"
|
gfx2.screen_mode(6)
|
||||||
str name2 = "irmen"
|
ubyte pix1 = gfx2.pget(162,120)
|
||||||
ubyte[] arr1 = [11,22,0,33]
|
gfx2.plot(162,120,7)
|
||||||
uword[] arr2 = [1111,2222,0,3333]
|
ubyte pix2 = gfx2.pget(162,120)
|
||||||
|
gfx2.plot(162,120,231)
|
||||||
sub start() {
|
ubyte pix3 = gfx2.pget(162,120)
|
||||||
sys.exit(42)
|
ubyte pix4 = gfx2.pget(163,120)
|
||||||
floats.rndseedf(11,22,33)
|
ubyte pix5 = gfx2.pget(162,121)
|
||||||
floats.print_f(floats.rndf())
|
sys.wait(20)
|
||||||
txt.nl()
|
gfx2.screen_mode(0)
|
||||||
floats.print_f(floats.rndf())
|
txt.print_ub(pix1)
|
||||||
txt.nl()
|
txt.spc()
|
||||||
floats.print_f(floats.rndf())
|
txt.print_ub(pix2)
|
||||||
txt.nl()
|
txt.spc()
|
||||||
|
txt.print_ub(pix3)
|
||||||
ubyte @shared xx
|
txt.spc()
|
||||||
ubyte value = 33
|
txt.print_ub(pix4)
|
||||||
uword value2 = 3333
|
txt.spc()
|
||||||
txt.print_ub(all(arr1))
|
txt.print_ub(pix5)
|
||||||
txt.print_ub(any(arr1))
|
txt.nl()
|
||||||
reverse(arr1)
|
}
|
||||||
sort(arr1)
|
|
||||||
txt.print_ub(value in name1)
|
|
||||||
txt.print_ub('c' in name1)
|
|
||||||
txt.print_ub(value in arr1)
|
|
||||||
txt.print_ub(value2 in arr2)
|
|
||||||
txt.print_ub(name1 == name2)
|
|
||||||
txt.print_ub(name1 < name2)
|
|
||||||
txt.print_ub(name1 >= name2)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user