mirror of
https://github.com/irmen/prog8.git
synced 2025-02-04 17:38:37 +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)
|
||||
set_both_strides(13) ; 160 increment = 1 line in 640 px 4c mode
|
||||
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]
|
||||
repeat lheight {
|
||||
%asm {{
|
||||
@ -561,7 +561,11 @@ _done
|
||||
and #1
|
||||
}}
|
||||
if_nz {
|
||||
cx16.r0L = lsb(x) & 7 ; xbits
|
||||
%asm {{
|
||||
lda x
|
||||
and #7
|
||||
pha ; xbits
|
||||
}}
|
||||
x /= 8
|
||||
x += y*(320/8)
|
||||
%asm {{
|
||||
@ -571,7 +575,7 @@ _done
|
||||
sta cx16.VERA_ADDR_M
|
||||
lda x
|
||||
sta cx16.VERA_ADDR_L
|
||||
ldy cx16.r0L ; xbits
|
||||
ply ; xbits
|
||||
lda bits,y
|
||||
ldy color
|
||||
beq +
|
||||
@ -608,7 +612,11 @@ _done
|
||||
and #1
|
||||
}}
|
||||
if_nz {
|
||||
cx16.r0L = lsb(x) & 7 ; xbits
|
||||
%asm {{
|
||||
lda x
|
||||
and #7
|
||||
pha ; xbits
|
||||
}}
|
||||
x /= 8
|
||||
x += y*(640/8)
|
||||
%asm {{
|
||||
@ -618,7 +626,7 @@ _done
|
||||
sta cx16.VERA_ADDR_M
|
||||
lda x
|
||||
sta cx16.VERA_ADDR_L
|
||||
ldy cx16.r0L ; xbits
|
||||
ply ; xbits
|
||||
lda bits,y
|
||||
ldy color
|
||||
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)
|
||||
cx16.r2L = lsb(x) & 3 ; xbits
|
||||
color &= 3
|
||||
color <<= shift4c[cx16.r2L]
|
||||
color <<= shift4c[cx16.r2L] ; TODO with lookup table
|
||||
%asm {{
|
||||
stz cx16.VERA_CTRL
|
||||
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) {
|
||||
ubyte bank
|
||||
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
|
||||
- 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 text inside the bitmap
|
||||
- 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
|
||||
^^^^^^^^^^^^^^^^
|
||||
- add a pget() to gfx2 to get the pixel color value
|
||||
- fix cx16/kefrenbars.p8
|
||||
- ir: write addresses as hex into p8ir file
|
||||
|
||||
...
|
||||
|
@ -1,39 +1,28 @@
|
||||
%import gfx2
|
||||
%import textio
|
||||
%import floats
|
||||
%import string
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
str name1 = "abc"
|
||||
str name2 = "irmen"
|
||||
ubyte[] arr1 = [11,22,0,33]
|
||||
uword[] arr2 = [1111,2222,0,3333]
|
||||
|
||||
sub start() {
|
||||
sys.exit(42)
|
||||
floats.rndseedf(11,22,33)
|
||||
floats.print_f(floats.rndf())
|
||||
txt.nl()
|
||||
floats.print_f(floats.rndf())
|
||||
txt.nl()
|
||||
floats.print_f(floats.rndf())
|
||||
txt.nl()
|
||||
|
||||
ubyte @shared xx
|
||||
ubyte value = 33
|
||||
uword value2 = 3333
|
||||
txt.print_ub(all(arr1))
|
||||
txt.print_ub(any(arr1))
|
||||
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)
|
||||
|
||||
}
|
||||
sub start() {
|
||||
gfx2.screen_mode(6)
|
||||
ubyte pix1 = gfx2.pget(162,120)
|
||||
gfx2.plot(162,120,7)
|
||||
ubyte pix2 = gfx2.pget(162,120)
|
||||
gfx2.plot(162,120,231)
|
||||
ubyte pix3 = gfx2.pget(162,120)
|
||||
ubyte pix4 = gfx2.pget(163,120)
|
||||
ubyte pix5 = gfx2.pget(162,121)
|
||||
sys.wait(20)
|
||||
gfx2.screen_mode(0)
|
||||
txt.print_ub(pix1)
|
||||
txt.spc()
|
||||
txt.print_ub(pix2)
|
||||
txt.spc()
|
||||
txt.print_ub(pix3)
|
||||
txt.spc()
|
||||
txt.print_ub(pix4)
|
||||
txt.spc()
|
||||
txt.print_ub(pix5)
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user