mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 03:54:27 +00:00
gfx2: changed screen mode numbering to a more intuitive sequence
This commit is contained in:
parent
857f930dc2
commit
52f6be2bb0
@ -6,28 +6,32 @@
|
|||||||
; Note: for compatible graphics code that words on C64 too, use the "graphics" module instead.
|
; Note: for compatible graphics code that words on C64 too, use the "graphics" module instead.
|
||||||
; Note: there is no color palette manipulation here, you have to do that yourself or use the "palette" module.
|
; Note: there is no color palette manipulation here, you have to do that yourself or use the "palette" module.
|
||||||
|
|
||||||
|
; SCREEN MODE LIST:
|
||||||
|
; mode 0 = reset back to default text mode
|
||||||
|
; mode 1 = bitmap 320 x 240 monochrome
|
||||||
|
; mode 2 = bitmap 320 x 240 x 4c (unsupported TODO not yet implemented)
|
||||||
|
; mode 3 = bitmap 320 x 240 x 16c (unsupported TODO not yet implemented)
|
||||||
|
; mode 4 = bitmap 320 x 240 x 256c
|
||||||
|
; mode 5 = bitmap 640 x 480 monochrome
|
||||||
|
; mode 6 = bitmap 640 x 480 x 4c (unsupported TODO not yet implemented)
|
||||||
|
; mode 7 = bitmap 640 x 480 x 16c (unsupported due to lack of VRAM)
|
||||||
|
; mode 8 = bitmap 640 x 480 x 256c (unsupported due to lack of VRAM)
|
||||||
|
|
||||||
; TODO can we make a FB vector table and emulation routines for the Cx16s' GRAPH_init() call? to replace the builtin 320x200 fb driver?
|
; TODO can we make a FB vector table and emulation routines for the Cx16s' GRAPH_init() call? to replace the builtin 320x200 fb driver?
|
||||||
|
|
||||||
gfx2 {
|
gfx2 {
|
||||||
|
|
||||||
; read-only control variables:
|
; read-only control variables:
|
||||||
ubyte active_mode = 255
|
ubyte active_mode = 0
|
||||||
uword width = 0
|
uword width = 0
|
||||||
uword height = 0
|
uword height = 0
|
||||||
ubyte bpp = 0
|
ubyte bpp = 0
|
||||||
ubyte monochrome_dont_stipple_flag = false ; set to false to enable stippling mode in monochrome displaymodes
|
ubyte monochrome_dont_stipple_flag = false ; set to false to enable stippling mode in monochrome displaymodes
|
||||||
|
|
||||||
sub screen_mode(ubyte mode) {
|
sub screen_mode(ubyte mode) {
|
||||||
; mode 0 = bitmap 320 x 240 x 1c monochrome
|
|
||||||
; mode 1 = bitmap 320 x 240 x 256c
|
|
||||||
; mode 128 = bitmap 640 x 480 x 1c monochrome
|
|
||||||
; ...other modes?
|
|
||||||
|
|
||||||
; copy the lower-case charset to the upper part of the vram, so we can use it later to plot text
|
|
||||||
|
|
||||||
when mode {
|
when mode {
|
||||||
0 -> {
|
1 -> {
|
||||||
; 320 x 240 x 1c
|
; lores monchrome
|
||||||
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11001111) | %00100000 ; enable only layer 1
|
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11001111) | %00100000 ; enable only layer 1
|
||||||
cx16.VERA_DC_HSCALE = 64
|
cx16.VERA_DC_HSCALE = 64
|
||||||
cx16.VERA_DC_VSCALE = 64
|
cx16.VERA_DC_VSCALE = 64
|
||||||
@ -38,8 +42,9 @@ gfx2 {
|
|||||||
height = 240
|
height = 240
|
||||||
bpp = 1
|
bpp = 1
|
||||||
}
|
}
|
||||||
1 -> {
|
; TODO modes 2, 3 not yet implemented
|
||||||
; 320 x 240 x 256c
|
4 -> {
|
||||||
|
; lores 256c
|
||||||
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11001111) | %00100000 ; enable only layer 1
|
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11001111) | %00100000 ; enable only layer 1
|
||||||
cx16.VERA_DC_HSCALE = 64
|
cx16.VERA_DC_HSCALE = 64
|
||||||
cx16.VERA_DC_VSCALE = 64
|
cx16.VERA_DC_VSCALE = 64
|
||||||
@ -50,8 +55,8 @@ gfx2 {
|
|||||||
height = 240
|
height = 240
|
||||||
bpp = 8
|
bpp = 8
|
||||||
}
|
}
|
||||||
128 -> {
|
5 -> {
|
||||||
; 640 x 480 x 1c
|
; highres monochrome
|
||||||
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11001111) | %00100000 ; enable only layer 1
|
cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11001111) | %00100000 ; enable only layer 1
|
||||||
cx16.VERA_DC_HSCALE = 128
|
cx16.VERA_DC_HSCALE = 128
|
||||||
cx16.VERA_DC_VSCALE = 128
|
cx16.VERA_DC_VSCALE = 128
|
||||||
@ -62,13 +67,16 @@ gfx2 {
|
|||||||
height = 480
|
height = 480
|
||||||
bpp = 1
|
bpp = 1
|
||||||
}
|
}
|
||||||
255 -> {
|
; TODO mode 6 highres 4c
|
||||||
|
; modes 7 and 8 not supported due to lack of VRAM
|
||||||
|
else -> {
|
||||||
; back to default text mode and colors
|
; back to default text mode and colors
|
||||||
cx16.VERA_CTRL = %10000000 ; reset VERA and palette
|
cx16.VERA_CTRL = %10000000 ; reset VERA and palette
|
||||||
c64.CINT() ; back to text mode
|
c64.CINT() ; back to text mode
|
||||||
width = 0
|
width = 0
|
||||||
height = 0
|
height = 0
|
||||||
bpp = 0
|
bpp = 0
|
||||||
|
mode = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,21 +89,24 @@ gfx2 {
|
|||||||
monochrome_stipple(false)
|
monochrome_stipple(false)
|
||||||
position(0, 0)
|
position(0, 0)
|
||||||
when active_mode {
|
when active_mode {
|
||||||
0 -> {
|
1 -> {
|
||||||
; 320 x 240 x 1c
|
; lores monochrome
|
||||||
repeat 240/2/8
|
repeat 240/2/8
|
||||||
cs_innerloop640()
|
cs_innerloop640()
|
||||||
}
|
}
|
||||||
1 -> {
|
; TODO mode 2, 3
|
||||||
; 320 x 240 x 256c
|
4 -> {
|
||||||
|
; lores 256c
|
||||||
repeat 240/2
|
repeat 240/2
|
||||||
cs_innerloop640()
|
cs_innerloop640()
|
||||||
}
|
}
|
||||||
128 -> {
|
5 -> {
|
||||||
; 640 x 480 x 1c
|
; highres monochrome
|
||||||
repeat 480/8
|
repeat 480/8
|
||||||
cs_innerloop640()
|
cs_innerloop640()
|
||||||
}
|
}
|
||||||
|
; TODO mode 6 highres 4c
|
||||||
|
; modes 7 and 8 not supported due to lack of VRAM
|
||||||
}
|
}
|
||||||
position(0, 0)
|
position(0, 0)
|
||||||
}
|
}
|
||||||
@ -130,8 +141,8 @@ gfx2 {
|
|||||||
if length==0
|
if length==0
|
||||||
return
|
return
|
||||||
when active_mode {
|
when active_mode {
|
||||||
1 -> {
|
4 -> {
|
||||||
; 8bpp mode
|
; lores 256c
|
||||||
position(x, y)
|
position(x, y)
|
||||||
%asm {{
|
%asm {{
|
||||||
lda color
|
lda color
|
||||||
@ -152,8 +163,8 @@ gfx2 {
|
|||||||
+ plx
|
+ plx
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
0, 128 -> {
|
1, 5 -> {
|
||||||
; 1 bpp mode
|
; monochrome modes, either resolution
|
||||||
ubyte separate_pixels = (8-lsb(x)) & 7
|
ubyte separate_pixels = (8-lsb(x)) & 7
|
||||||
if separate_pixels as uword > length
|
if separate_pixels as uword > length
|
||||||
separate_pixels = lsb(length)
|
separate_pixels = lsb(length)
|
||||||
@ -212,7 +223,8 @@ _done
|
|||||||
|
|
||||||
sub vertical_line(uword x, uword y, uword height, ubyte color) {
|
sub vertical_line(uword x, uword y, uword height, ubyte color) {
|
||||||
position(x,y)
|
position(x,y)
|
||||||
if active_mode==1 {
|
if active_mode==4 {
|
||||||
|
; lores 256c
|
||||||
; set vera auto-increment to 320 pixel increment (=next line)
|
; set vera auto-increment to 320 pixel increment (=next line)
|
||||||
cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) | (14<<4)
|
cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) | (14<<4)
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -230,7 +242,7 @@ _done
|
|||||||
; note for the 1 bpp modes we can't use vera's auto increment mode because we have to 'or' the pixel data in place.
|
; note for the 1 bpp modes we can't use vera's auto increment mode because we have to 'or' the pixel data in place.
|
||||||
cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) ; no auto advance
|
cx16.VERA_ADDR_H = (cx16.VERA_ADDR_H & %00000111) ; no auto advance
|
||||||
cx16.r15 = gfx2.plot.bits[x as ubyte & 7] ; bitmask
|
cx16.r15 = gfx2.plot.bits[x as ubyte & 7] ; bitmask
|
||||||
if active_mode>=128
|
if active_mode>=5
|
||||||
cx16.r14 = 640/8
|
cx16.r14 = 640/8
|
||||||
else
|
else
|
||||||
cx16.r14 = 320/8
|
cx16.r14 = 320/8
|
||||||
@ -472,7 +484,8 @@ _done
|
|||||||
ubyte value
|
ubyte value
|
||||||
|
|
||||||
when active_mode {
|
when active_mode {
|
||||||
0 -> {
|
1 -> {
|
||||||
|
; lores monochrome
|
||||||
%asm {{
|
%asm {{
|
||||||
lda x
|
lda x
|
||||||
eor y
|
eor y
|
||||||
@ -490,7 +503,8 @@ _done
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
128 -> {
|
5 -> {
|
||||||
|
; highres monochrome
|
||||||
%asm {{
|
%asm {{
|
||||||
lda x
|
lda x
|
||||||
eor y
|
eor y
|
||||||
@ -508,7 +522,8 @@ _done
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1 -> {
|
4 -> {
|
||||||
|
; lores 256c
|
||||||
void addr_mul_320_add_24(y, x) ; 24 bits result is in r0 and r1L
|
void addr_mul_320_add_24(y, x) ; 24 bits result is in r0 and r1L
|
||||||
value = lsb(cx16.r1)
|
value = lsb(cx16.r1)
|
||||||
cx16.vpoke(value, cx16.r0, color)
|
cx16.vpoke(value, cx16.r0, color)
|
||||||
@ -521,15 +536,18 @@ _done
|
|||||||
|
|
||||||
sub position(uword @zp x, uword y) {
|
sub position(uword @zp x, uword y) {
|
||||||
when active_mode {
|
when active_mode {
|
||||||
0 -> {
|
1 -> {
|
||||||
|
; lores monochrome
|
||||||
cx16.r0 = y*(320/8) + x/8
|
cx16.r0 = y*(320/8) + x/8
|
||||||
cx16.vaddr(0, cx16.r0, 0, 1)
|
cx16.vaddr(0, cx16.r0, 0, 1)
|
||||||
}
|
}
|
||||||
128 -> {
|
5 -> {
|
||||||
|
; highres monochrome
|
||||||
cx16.r0 = y*(640/8) + x/8
|
cx16.r0 = y*(640/8) + x/8
|
||||||
cx16.vaddr(0, cx16.r0, 0, 1)
|
cx16.vaddr(0, cx16.r0, 0, 1)
|
||||||
}
|
}
|
||||||
1 -> {
|
4 -> {
|
||||||
|
; lores 256c
|
||||||
void addr_mul_320_add_24(y, x) ; 24 bits result is in r0 and r1L
|
void addr_mul_320_add_24(y, x) ; 24 bits result is in r0 and r1L
|
||||||
ubyte bank = lsb(cx16.r1)
|
ubyte bank = lsb(cx16.r1)
|
||||||
cx16.vaddr(bank, cx16.r0, 0, 1)
|
cx16.vaddr(bank, cx16.r0, 0, 1)
|
||||||
@ -614,13 +632,13 @@ _done
|
|||||||
sub text(uword @zp x, uword y, ubyte color, uword sctextptr) {
|
sub text(uword @zp x, uword y, ubyte color, uword sctextptr) {
|
||||||
; -- Write some text at the given pixel position. The text string must be in screencode encoding (not petscii!).
|
; -- Write some text at the given pixel position. The text string must be in screencode encoding (not petscii!).
|
||||||
; You must also have called text_charset() first to select and prepare the character set to use.
|
; You must also have called text_charset() first to select and prepare the character set to use.
|
||||||
; NOTE: in monochrome (1bpp) screen modes, x position is currently constrained to mulitples of 8 !
|
; NOTE: in monochrome (1bpp) screen modes, x position is currently constrained to mulitples of 8 ! TODO allow per-pixel horizontal positioning
|
||||||
uword chardataptr
|
uword chardataptr
|
||||||
when active_mode {
|
when active_mode {
|
||||||
0, 128 -> {
|
1, 5 -> {
|
||||||
; 1-bitplane modes
|
; monochrome mode, either resolution
|
||||||
cx16.r2 = 40
|
cx16.r2 = 40
|
||||||
if active_mode>=128
|
if active_mode>=5
|
||||||
cx16.r2 = 80
|
cx16.r2 = 80
|
||||||
while @(sctextptr) {
|
while @(sctextptr) {
|
||||||
chardataptr = charset_addr + (@(sctextptr) as uword)*8
|
chardataptr = charset_addr + (@(sctextptr) as uword)*8
|
||||||
@ -660,8 +678,8 @@ _done
|
|||||||
sctextptr++
|
sctextptr++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1 -> {
|
4 -> {
|
||||||
; 320 x 240 x 256c
|
; lores 256c
|
||||||
while @(sctextptr) {
|
while @(sctextptr) {
|
||||||
chardataptr = charset_addr + (@(sctextptr) as uword)*8
|
chardataptr = charset_addr + (@(sctextptr) as uword)*8
|
||||||
cx16.vaddr(charset_bank, chardataptr, 1, 1)
|
cx16.vaddr(charset_bank, chardataptr, 1, 1)
|
||||||
|
@ -11,7 +11,7 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
palette.set_monochrome($0aaa, $0000)
|
palette.set_monochrome($0aaa, $0000)
|
||||||
gfx2.screen_mode(128) ; select 640*480 mode
|
gfx2.screen_mode(5) ; select 640*480 mode
|
||||||
cx16.VERA_DC_VSCALE = 64 ; have the vertical resolution so it is 640*240 - more or less Amiga's default non interlaced mode
|
cx16.VERA_DC_VSCALE = 64 ; have the vertical resolution so it is 640*240 - more or less Amiga's default non interlaced mode
|
||||||
cx16.mouse_config(1, 1) ; enable mouse TODO make it an Amiga mouse pointer if possible
|
cx16.mouse_config(1, 1) ; enable mouse TODO make it an Amiga mouse pointer if possible
|
||||||
gfx2.text_charset(3)
|
gfx2.text_charset(3)
|
||||||
|
@ -11,12 +11,12 @@ main {
|
|||||||
|
|
||||||
test_monochrome()
|
test_monochrome()
|
||||||
|
|
||||||
gfx2.screen_mode(255)
|
gfx2.screen_mode(0)
|
||||||
txt.print("done!\n")
|
txt.print("done!\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_monochrome() {
|
sub test_monochrome() {
|
||||||
gfx2.screen_mode(128)
|
gfx2.screen_mode(5)
|
||||||
uword yy
|
uword yy
|
||||||
uword xx
|
uword xx
|
||||||
word ww
|
word ww
|
||||||
|
@ -7,8 +7,19 @@
|
|||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
gfx2.screen_mode(128)
|
gfx2.screen_mode(5)
|
||||||
|
|
||||||
|
; demo1()
|
||||||
|
; sys.wait(3*60)
|
||||||
|
demo2()
|
||||||
|
|
||||||
|
gfx2.screen_mode(0)
|
||||||
|
txt.print("done!\n")
|
||||||
|
|
||||||
|
test_stack.test()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub demo1() {
|
||||||
uword pixels = memory("pixels", 320)
|
uword pixels = memory("pixels", 320)
|
||||||
uword yy = 10
|
uword yy = 10
|
||||||
uword xx
|
uword xx
|
||||||
@ -124,21 +135,12 @@ main {
|
|||||||
}
|
}
|
||||||
xx+=4
|
xx+=4
|
||||||
}
|
}
|
||||||
|
|
||||||
sys.wait(3*60)
|
|
||||||
|
|
||||||
demo2()
|
|
||||||
|
|
||||||
gfx2.screen_mode(255)
|
|
||||||
txt.print("done!\n")
|
|
||||||
|
|
||||||
test_stack.test()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub demo2 () {
|
sub demo2 () {
|
||||||
gfx2.text_charset(3)
|
gfx2.text_charset(3)
|
||||||
|
|
||||||
ubyte[] modes = [1, 0, 128]
|
ubyte[] modes = [4, 1, 5]
|
||||||
ubyte mode
|
ubyte mode
|
||||||
for mode in modes {
|
for mode in modes {
|
||||||
gfx2.screen_mode(mode)
|
gfx2.screen_mode(mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user