This commit is contained in:
Irmen de Jong 2021-02-01 22:18:00 +01:00
parent c478718019
commit 76f459ee95
3 changed files with 50 additions and 25 deletions

View File

@ -1,11 +1,15 @@
%target cx16
; Bitmap pixel graphics module for the CommanderX16
; Bitmap pixel graphics routines for the CommanderX16
; Custom routines to use the full-screen 640x480 and 320x240 screen modes.
; These modes are not supported by the documented GRAPH_xxxx kernel routines.
; (These modes are not supported by the documented GRAPH_xxxx kernel routines)
;
; No text layer is currently shown, text can be drawn as part of the bitmap itself.
; Note: for similar graphics routines that also work on the C-64, use the "graphics" module instead.
; Note: for color palette manipulation, use the "palette" module or write Vera registers yourself.
; Note: this library implements code for various resolutions and color depths. This takes up memory.
; If you're memory constrained you should probably not use this built-in library,
; but make a copy in your project only containing the code for the required resolution.
;
;
; SCREEN MODE LIST:
@ -21,9 +25,6 @@
; 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 split out the various when blocks in to their own subroutines so the assembler can omit unused code.
gfx2 {
; read-only control variables:
@ -643,11 +644,11 @@ _done
cx16.r0 = y*(320/8) + x/8
cx16.vaddr(0, cx16.r0, 0, 1)
}
; TODO modes 2,3
4 -> {
; lores 256c
void addr_mul_24_for_lores_256c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
ubyte bank = lsb(cx16.r1)
cx16.vaddr(bank, cx16.r0, 0, 1)
cx16.vaddr(lsb(cx16.r1), cx16.r0, 0, 1)
}
5 -> {
; highres monochrome
@ -656,8 +657,8 @@ _done
}
6 -> {
; highres 4c
cx16.r0 = y*(640/4) + x/8
cx16.vaddr(0, cx16.r0, 0, 1)
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte)
cx16.vaddr(lsb(cx16.r1), cx16.r0, 0, 1)
}
}
}
@ -816,6 +817,28 @@ _done
sctextptr++
}
}
6 -> {
; hires 4c
while @(sctextptr) {
chardataptr = charset_addr + (@(sctextptr) as uword)*8
repeat 8 {
; TODO rewrite this inner loop in assembly
ubyte charbits = cx16.vpeek(charset_bank, chardataptr)
repeat 8 {
charbits <<= 1
if_cs
plot(x, y, color)
x++
}
x-=8
chardataptr++
y++
}
x+=8
y-=8
sctextptr++
}
}
}
}
@ -839,8 +862,12 @@ _done
sub addr_mul_24_for_highres_4c(uword yy, uword xx) {
; TODO asmsub, actually do 24 bits calc
; 24 bits result is in r0 and r1L (highest byte)
cx16.r0 = xx/4 + yy*(640/4)
cx16.r0 = yy*128
cx16.r2 = yy*32
cx16.r1 = 0
cx16.r0 += cx16.r2
cx16.r0 += xx/4
}
asmsub addr_mul_24_for_lores_256c(uword yy @R0, uword xx @AY) clobbers(A) -> uword @R0, ubyte @R1 {

View File

@ -1262,7 +1262,7 @@ mul_word_100 .proc
.pend
mul_word_320 .proc
; AY = A * 256 + A * 64 (msb doesn't matter)
; AY = A * 256 + A * 64 (msb in Y doesn't matter)
sta P8ZP_SCRATCH_B1
ldy #0
sty P8ZP_SCRATCH_REG

View File

@ -13,13 +13,8 @@ main {
palette.set_rgb(amigacolors, len(amigacolors))
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 shape & colors if possible
gfx2.text_charset(3)
if gfx2.active_mode==5 {
gfx2.monochrome_stipple(true)
gfx2.fillrect(0,11,gfx2.width,gfx2.height/2-11,1)
gfx2.monochrome_stipple(false)
}
screen_titlebar()
window_workbench()
@ -128,12 +123,8 @@ widget {
uword middlex = x+width/2+1
ubyte halfstring = string.length(caption) * 4
gfx2.text(middlex-halfstring,y+height+1,1,caption)
gfx2.monochrome_stipple(true)
gfx2.disc(x+width/4+4, y+height/2, height/2-4, 1)
gfx2.monochrome_stipple(false)
gfx2.circle(x+width/4+4, y+height/2, height/2-4, 1)
gfx2.fillrect(x+20,y+12,width/2,height/2-4,1)
gfx2.disc(x+width/4+4, y+height/2, height/2-3, 1)
gfx2.fillrect(x+20,y+12,width/2,height/2-4,3)
}
@ -203,7 +194,14 @@ widget {
gfx2.line(x+width-1-13,y+height-3, x+width-1-3, y+height-3-5, 1)
gfx2.horizontal_line(x+width-1-16, y+height-10, 16, 2)
highlightedrect(x+width-13, y+12, 10, height-23, false, false)
; TODO scroll icons
highlightedrect(x+width-13, y+12, 10, height-43, false, false)
gfx2.horizontal_line(x+width-1-16, y+height-11, 16, 1)
gfx2.horizontal_line(x+width-1-16, y+height-20, 16, 2)
gfx2.horizontal_line(x+width-1-16, y+height-21, 16, 1)
gfx2.horizontal_line(x+width-1-16, y+height-30, 16, 2)
gfx2.line(x+width-1-12, y+height-23, x+width-8, y+height-28, 1)
gfx2.line(x+width-1-3, y+height-23, x+width-9, y+height-28, 1)
gfx2.line(x+width-1-13, y+height-18, x+width-8, y+height-13, 1)
gfx2.line(x+width-1-3, y+height-18, x+width-9, y+height-13, 1)
}
}