added mouse cursor to amiga example

slightly sped up text rendering in gfx2 highres mode
This commit is contained in:
Irmen de Jong 2022-08-16 03:50:36 +02:00
parent 40aa733ea7
commit 6454bf8ec4
3 changed files with 54 additions and 7 deletions

View File

@ -844,25 +844,28 @@ _done
}
6 -> {
; hires 4c
; we're going to use a few cx16 registers to make sure every variable is in zeropage in the inner loop.
cx16.r11L = color
cx16.r8 = y
while @(sctextptr) {
chardataptr = charset_addr + (@(sctextptr) as uword)*8
repeat 8 {
; TODO rewrite this inner loop partly in assembly
; requires expanding the charbits to 2-bits per pixel (based on color)
; also it's way more efficient to draw whole horizontal spans instead of per-character
ubyte charbits = cx16.vpeek(charset_bank, chardataptr)
cx16.r9L = cx16.vpeek(charset_bank, chardataptr) ; get the 8 horizontal character bits
cx16.r7 = x
repeat 8 {
charbits <<= 1
cx16.r9L <<= 1
if_cs
plot(x, y, color)
x++
plot(cx16.r7, cx16.r8, cx16.r11L)
cx16.r7++
}
x-=8
chardataptr++
y++
cx16.r8++
}
x+=8
y-=8
cx16.r8-=8
sctextptr++
}
}

View File

@ -3,6 +3,7 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- check that subs with single integer arg are passing that in A or AY (and the sub itself stores it in the parameter variable)
- vm: intermediate code: don't flatten everything. Instead, as a new intermediary step,
convert the new Ast into *structured* intermediary code.
Basically keep the blocks and subroutines structure, including full subroutine signature information,

View File

@ -9,6 +9,8 @@ main {
sub start() {
gfx2.screen_mode(6) ; select 640*480 mode, 4 colors
mouse.set_pointer_image()
cx16.mouse_config(-1, 640/8, 240/8)
uword[4] amigacolors = [$aaa, $000, $fff, $68c] ; gray, black, white, lightblue
palette.set_rgb(amigacolors, len(amigacolors))
@ -99,7 +101,48 @@ main {
}
}
mouse {
sub set_pointer_image() {
const uword sprite_data_addr = $a000
const ubyte palette_offset = 16
; sprite registers base in VRAM: $1fc00
; Sprite 0: $1FC00 - $1FC07 ; used by the kernal for mouse pointer
cx16.vpoke(1, $fc00, lsb(sprite_data_addr >> 5)) ; sprite data ptr bits 5-12
cx16.vpoke(1, $fc01, msb(sprite_data_addr >> 5)) ; mode bit (16 colors = 4 bpp) and sprite dataptr bits 13-16
cx16.vpoke(1, $fc07, %01100000 | palette_offset>>4) ; 32x16 pixels (non-square...), palette offset
ubyte ix
for ix in 0 to 255 {
cx16.vpoke(0, sprite_data_addr+ix, mousecursor[ix])
}
palette.set_color(palette_offset + %1111, $f00)
palette.set_color(palette_offset + %1010, $fff)
palette.set_color(palette_offset + %0101, $000)
ubyte[256] mousecursor = [
; The Amiga Workbench 3.0 mouse cursor sprite image.
; note that the sprite resolution is 32x16 (non-square pixels) because it follows the bitmap screen resolution
; %1111 = red, %1010 = white, %0101 = black, %0000 = transparent
%11111111,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%01010101,%11111111,%10101010,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%01010101,%11111111,%11111111,%10101010,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%01010101,%11111111,%11111111,%11111111,%11111111,%10101010,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%01010101,%11111111,%11111111,%11111111,%11111111,%11111111,%10101010,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%01010101,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%11111111,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%01010101,%11111111,%11111111,%11111111,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%01010101,%11111111,%11111111,%01010101,%11111111,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%01010101,%11111111,%00000000,%01010101,%11111111,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%01010101,%11111111,%00000000,%00000000,%01010101,%11111111,%10101010,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01010101,%11111111,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
]
}
}
widget {