mirror of
https://github.com/irmen/prog8.git
synced 2025-02-02 04:30:46 +00:00
vtui example updated to vtui 0.6
This commit is contained in:
parent
4e640b11fd
commit
2b435fe6a5
@ -15,13 +15,12 @@
|
||||
; 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 2 = bitmap 320 x 240 x 4c (TODO not yet implemented)
|
||||
; mode 3 = bitmap 320 x 240 x 16c (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
|
||||
; 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)
|
||||
; higher color dephts in highres are not supported 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?
|
||||
|
||||
@ -85,7 +84,6 @@ gfx2 {
|
||||
height = 480
|
||||
bpp = 2
|
||||
}
|
||||
; modes 7 and 8 not supported due to lack of VRAM
|
||||
else -> {
|
||||
; back to default text mode and colors
|
||||
cx16.VERA_CTRL = %10000000 ; reset VERA and palette
|
||||
@ -168,7 +166,7 @@ gfx2 {
|
||||
if separate_pixels as uword > length
|
||||
separate_pixels = lsb(length)
|
||||
repeat separate_pixels {
|
||||
; this could be optimized by setting this byte in 1 go but probably not worth it due to code size
|
||||
; TODO optimize this by writing a masked byte in 1 go
|
||||
plot(x, y, color)
|
||||
x++
|
||||
}
|
||||
@ -210,7 +208,7 @@ _loop lda length
|
||||
_done
|
||||
}}
|
||||
repeat separate_pixels {
|
||||
; this could be optimized by setting this byte in 1 go but probably not worth it due to code size
|
||||
; TODO optimize this by writing a masked byte in 1 go
|
||||
plot(x, y, color)
|
||||
x++
|
||||
}
|
||||
@ -299,6 +297,7 @@ _done
|
||||
1, 5 -> {
|
||||
; monochrome, either resolution
|
||||
; 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.
|
||||
; TODO use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment IS possible
|
||||
cx16.VERA_ADDR_H &= %00000111 ; no auto advance
|
||||
cx16.r15 = gfx2.plot.bits[x as ubyte & 7] ; bitmask
|
||||
if active_mode>=5
|
||||
@ -326,7 +325,7 @@ _done
|
||||
}
|
||||
} else {
|
||||
; stippling.
|
||||
height = (height+1)/2
|
||||
height = (height+1)/2 ; TODO is the line sometimes 1 pixel too long now because of rounding?
|
||||
%asm {{
|
||||
lda x
|
||||
eor y
|
||||
@ -375,7 +374,8 @@ _done
|
||||
lda cx16.VERA_ADDR_M
|
||||
adc #0
|
||||
sta cx16.VERA_ADDR_M
|
||||
; lda cx16.VERA_ADDR_H ; the bitmap size is small enough to not have to deal with the _H part.
|
||||
; the bitmap size is small enough to not have to deal with the _H part:
|
||||
; lda cx16.VERA_ADDR_H
|
||||
; adc #0
|
||||
; sta cx16.VERA_ADDR_H
|
||||
}}
|
||||
@ -399,6 +399,7 @@ _done
|
||||
6 -> {
|
||||
; highres 4c
|
||||
; note for this mode we can't use vera's auto increment mode because we have to 'or' the pixel data in place.
|
||||
; TODO use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment IS possible
|
||||
cx16.VERA_ADDR_H &= %00000111 ; no auto advance
|
||||
; TODO also mostly usable for lores 4c?
|
||||
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
|
||||
@ -928,48 +929,48 @@ _done
|
||||
}
|
||||
|
||||
asmsub addr_mul_24_for_lores_256c(uword yy @R0, uword xx @AY) clobbers(A) -> uword @R0, ubyte @R1 {
|
||||
; yy * 320 + xx (24 bits calculation)
|
||||
%asm {{
|
||||
sta P8ZP_SCRATCH_W1
|
||||
sty P8ZP_SCRATCH_W1+1
|
||||
lda cx16.r0
|
||||
sta P8ZP_SCRATCH_B1
|
||||
lda cx16.r0+1
|
||||
sta cx16.r1
|
||||
sta P8ZP_SCRATCH_REG
|
||||
lda cx16.r0
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
sta cx16.r0
|
||||
lda P8ZP_SCRATCH_B1
|
||||
clc
|
||||
adc P8ZP_SCRATCH_REG
|
||||
sta cx16.r0+1
|
||||
bcc +
|
||||
inc cx16.r1
|
||||
+ ; now add the value to this 24-bits number
|
||||
lda cx16.r0
|
||||
clc
|
||||
adc P8ZP_SCRATCH_W1
|
||||
sta cx16.r0
|
||||
lda cx16.r0+1
|
||||
adc P8ZP_SCRATCH_W1+1
|
||||
sta cx16.r0+1
|
||||
bcc +
|
||||
inc cx16.r1
|
||||
+ lda cx16.r1
|
||||
rts
|
||||
}}
|
||||
}
|
||||
; yy * 320 + xx (24 bits calculation)
|
||||
%asm {{
|
||||
sta P8ZP_SCRATCH_W1
|
||||
sty P8ZP_SCRATCH_W1+1
|
||||
lda cx16.r0
|
||||
sta P8ZP_SCRATCH_B1
|
||||
lda cx16.r0+1
|
||||
sta cx16.r1
|
||||
sta P8ZP_SCRATCH_REG
|
||||
lda cx16.r0
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
asl a
|
||||
rol P8ZP_SCRATCH_REG
|
||||
sta cx16.r0
|
||||
lda P8ZP_SCRATCH_B1
|
||||
clc
|
||||
adc P8ZP_SCRATCH_REG
|
||||
sta cx16.r0+1
|
||||
bcc +
|
||||
inc cx16.r1
|
||||
+ ; now add the value to this 24-bits number
|
||||
lda cx16.r0
|
||||
clc
|
||||
adc P8ZP_SCRATCH_W1
|
||||
sta cx16.r0
|
||||
lda cx16.r0+1
|
||||
adc P8ZP_SCRATCH_W1+1
|
||||
sta cx16.r0+1
|
||||
bcc +
|
||||
inc cx16.r1
|
||||
+ lda cx16.r1
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ palette {
|
||||
$666, ; 12 = medium grey
|
||||
$9D8, ; 13 = light green
|
||||
$65B, ; 14 = light blue
|
||||
$999 ; 15 = light grey
|
||||
$999 ; 15 = light grey
|
||||
]
|
||||
|
||||
uword[] C64_colorpalette_pepto = [ ; # this is Pepto's Commodore-64 palette http://www.pepto.de/projects/colorvic/
|
||||
@ -119,7 +119,7 @@ palette {
|
||||
$777, ; 12 = medium grey
|
||||
$af9, ; 13 = light green
|
||||
$76e, ; 14 = light blue
|
||||
$bbb ; 15 = light grey
|
||||
$bbb ; 15 = light grey
|
||||
]
|
||||
|
||||
uword[] C64_colorpalette_light = [ ; this is a lighter palette
|
||||
|
@ -462,7 +462,7 @@ asmsub init_system() {
|
||||
cld
|
||||
;stz $00
|
||||
;stz $01
|
||||
;stz d1prb ; select rom bank 0
|
||||
;stz d1prb ; select rom bank 0 (enable kernal)
|
||||
lda #$80
|
||||
sta VERA_CTRL
|
||||
jsr c64.IOINIT
|
||||
|
@ -1 +1 @@
|
||||
6.2-SNAPSHOT
|
||||
6.2
|
||||
|
@ -377,7 +377,7 @@ internal class StatementReorderer(val program: Program, val errors: IErrorReport
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
// TODO use memcopy instead of individual assignments
|
||||
// TODO use memcopy instead of individual assignments after certain amount of elements
|
||||
// TODO what does assigning a struct var use?
|
||||
return alv.value.mapIndexed { index, value ->
|
||||
val idx = ArrayIndexedExpression(identifier, ArrayIndex(NumericLiteralValue(DataType.UBYTE, index, position), position), position)
|
||||
|
@ -2,9 +2,10 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- optimize assigning array and struct variables (multi-element assings -> memcopy)
|
||||
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
|
||||
- optimize swap of two memread values with index, using the same pointer expression/variable, like swap(@(ptr+1), @(ptr+2))
|
||||
- optimize several inner loops in gfx2 (highres 4 color mode)
|
||||
- optimize several inner loops in gfx2
|
||||
- try to fix the bresenham line routines in graphics and gfx2 (sometimes they're a pixel 'off')
|
||||
- add modes 2 and 3 to gfx2 (lowres 4 color and 16 color)
|
||||
- add a flood fill routine to gfx2?
|
||||
|
Binary file not shown.
@ -1,14 +1,18 @@
|
||||
%target cx16
|
||||
%import textio
|
||||
%zeropage dontuse
|
||||
%option no_sysinit
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
; todo feedback: new routines at the end of the jump table so existing jump vectors remain unchanged
|
||||
|
||||
txt.lowercase()
|
||||
|
||||
vtui.initialize()
|
||||
vtui.screen_set(2)
|
||||
vtui.gotoxy(0,0)
|
||||
vtui.fill_box(':', 80, 60, $c6)
|
||||
vtui.clr_scr('%', $50)
|
||||
vtui.gotoxy(5,5)
|
||||
vtui.fill_box(':', 70, 50, $c6)
|
||||
vtui.gotoxy(10,10)
|
||||
vtui.border(1, 40, 6, $47)
|
||||
vtui.gotoxy(12,12)
|
||||
@ -19,12 +23,75 @@ main {
|
||||
repeat {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub logo_mover() {
|
||||
ubyte xcoord
|
||||
ubyte ycoord
|
||||
ubyte newx
|
||||
ubyte newy
|
||||
|
||||
vtui.initialize()
|
||||
;vtui.screen_set(2)
|
||||
vtui.gotoxy(30, 32)
|
||||
vtui.print_str("arrow keys to move!", $61, 0)
|
||||
vtui.gotoxy(0, 0)
|
||||
vtui.save_rect(1, 1, $0000, 7, 7)
|
||||
vtui.gotoxy(0, 0)
|
||||
vtui.save_rect(1, 1, $0100, 7, 7)
|
||||
|
||||
char_loop:
|
||||
ubyte char = c64.GETIN()
|
||||
if not char
|
||||
goto char_loop
|
||||
|
||||
when char {
|
||||
$91 -> {
|
||||
if newy {
|
||||
newy--
|
||||
move_logo()
|
||||
}
|
||||
}
|
||||
$11 -> {
|
||||
if newy<53 {
|
||||
newy++
|
||||
move_logo()
|
||||
}
|
||||
}
|
||||
$9d -> {
|
||||
if newx {
|
||||
newx--
|
||||
move_logo()
|
||||
}
|
||||
}
|
||||
$1d -> {
|
||||
if newx<70 {
|
||||
newx++
|
||||
move_logo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
goto char_loop
|
||||
|
||||
sub move_logo() {
|
||||
vtui.gotoxy(xcoord, ycoord)
|
||||
vtui.rest_rect(1, 1, $0100, 7, 7)
|
||||
vtui.gotoxy(newx, newy)
|
||||
vtui.save_rect(1, 1, $0100, 7, 7)
|
||||
vtui.gotoxy(newx, newy)
|
||||
vtui.rest_rect(1, 1, $0000, 7, 7)
|
||||
xcoord = newx
|
||||
ycoord = newy
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
vtui $1000 {
|
||||
|
||||
%asmbinary "VTUI0.5.BIN", 2 ; skip the 2 dummy load address bytes
|
||||
%asmbinary "VTUI0.6.BIN", 2 ; skip the 2 dummy load address bytes
|
||||
|
||||
; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons!
|
||||
romsub $1000 = initialize() clobbers(A, X, Y)
|
||||
@ -32,16 +99,17 @@ vtui $1000 {
|
||||
romsub $1005 = set_bank(ubyte bank @Pc) clobbers(A)
|
||||
romsub $1008 = set_stride(ubyte stride @A) clobbers(A)
|
||||
romsub $100b = set_decr(ubyte incrdecr @Pc) clobbers(A)
|
||||
romsub $100e = gotoxy(ubyte column @A, ubyte row @Y)
|
||||
romsub $1011 = plot_char(ubyte char @A, ubyte colors @X)
|
||||
romsub $1014 = scan_char() -> ubyte @A, ubyte @X
|
||||
romsub $1017 = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $101a = vline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $101d = print_str(str string @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
||||
romsub $1020 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y)
|
||||
romsub $1023 = pet2scr(ubyte char @A) -> ubyte @A
|
||||
romsub $1026 = scr2pet(ubyte char @A) -> ubyte @A
|
||||
romsub $1029 = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6
|
||||
romsub $102c = save_rect(ubyte ramtype @Pc, ubyte vbank @A, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
romsub $102f = rest_rect(ubyte ramtype @Pc, ubyte vbank @A, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
romsub $100e = clr_scr(ubyte char @A, ubyte colors @X) clobbers(Y)
|
||||
romsub $1011 = gotoxy(ubyte column @A, ubyte row @Y)
|
||||
romsub $1014 = plot_char(ubyte char @A, ubyte colors @X)
|
||||
romsub $1017 = scan_char() -> ubyte @A, ubyte @X
|
||||
romsub $101a = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $101d = vline(ubyte char @A, ubyte height @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $1020 = print_str(str string @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
||||
romsub $1023 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y)
|
||||
romsub $1026 = pet2scr(ubyte char @A) -> ubyte @A
|
||||
romsub $1029 = scr2pet(ubyte char @A) -> ubyte @A
|
||||
romsub $102c = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6
|
||||
romsub $102f = save_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
romsub $1032 = rest_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user