1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-08 14:37:40 +00:00

Updates to make the demo even more compelling. I will continue now with other VERA mode settings.

This commit is contained in:
FlightControl 2021-01-13 08:30:58 +01:00
parent 1333e3c21a
commit b812c76427
5 changed files with 127 additions and 23 deletions

View File

@ -4878,3 +4878,34 @@ sta {z1}
lda {z2}+1
adc {c1}+1,y
sta {z1}+1
//FRAGMENT _deref_(_deref_qbuc1)=vbuz1
lda {z1}
ldy {c1}
sty $fe
ldy {c1}+1
sty $ff
ldy #0
sta ($fe),y
//FRAGMENT _deref_(_deref_qbuc1)=vbuaa
ldy {c1}
sty $fe
ldy {c1}+1
sty $ff
ldy #0
sta ($fe),y
//FRAGMENT _deref_(_deref_qbuc1)=vbuxx
txa
ldy {c1}
sty $fe
ldy {c1}+1
sty $ff
ldy #0
sta ($fe),y
//FRAGMENT _deref_(_deref_qbuc1)=vbuyy
tya
ldy {c1}
sty $fe
ldy {c1}+1
sty $ff
ldy #0
sta ($fe),y

View File

@ -13,7 +13,7 @@ const char YELLOW = 0x7;
const char ORANGE = 0x8;
const char BROWN = 0x9;
const char PINK = 0xa;
const char DARK_GREY= 0xb;
const char DARK_GREY = 0xb;
const char GREY = 0xc;
const char LIGHT_GREEN = 0xd;
const char LIGHT_BLUE = 0xe;

View File

@ -106,3 +106,13 @@ unsigned byte vera_get_layer_backcolor(unsigned byte layer);
// This will only work when the VERA is in 16 color mode!
// Note that on the VERA, the transparent color has value 0.
unsigned byte vera_get_layer_color(unsigned byte layer);
// Scroll the horizontal (X) axis of the layer visible area over the layer tile map area.
// - layer: Value of 0 or 1.
// - scroll: A value between 0 and 4096.
inline void vera_set_layer_horizontal_scroll(byte layer, word scroll);
// Scroll the vertical (Y) axis of the layer visible area over the layer tile map area.
// - layer: Value of 0 or 1.
// - scroll: A value between 0 and 4096.
inline void vera_set_layer_vertical_scroll(byte layer, word scroll);

View File

@ -14,12 +14,15 @@ __ma byte vera_layer_enable[2] = { VERA_LAYER0_ENABLE, VERA_LAYER1_ENABLE };
__ma byte* vera_layer_mapbase[2] = {VERA_L0_MAPBASE, VERA_L1_MAPBASE};
__ma byte* vera_layer_tilebase[2] = {VERA_L0_TILEBASE, VERA_L1_TILEBASE};
__ma byte* vera_layer_vscroll_l[2] = {VERA_L0_VSCROLL_L, VERA_L1_VSCROLL_L};
__ma byte* vera_layer_vscroll_h[2] = {VERA_L0_VSCROLL_H, VERA_L1_VSCROLL_H};
__ma byte* vera_layer_hscroll_l[2] = {VERA_L0_HSCROLL_L, VERA_L1_HSCROLL_L};
__ma byte* vera_layer_hscroll_h[2] = {VERA_L0_HSCROLL_H, VERA_L1_HSCROLL_H};
__ma byte vera_layer_textcolor[2] = {WHITE, WHITE};
__ma byte vera_layer_backcolor[2] = {BLUE, BLUE};
// --- VERA addressing ---
void vera_vram_address0(dword bankaddr, byte incr) {
@ -258,3 +261,20 @@ unsigned byte vera_get_layer_color(unsigned byte layer) {
layer &= $1;
return ((vera_layer_backcolor[layer] << 4) | vera_layer_textcolor[layer]);
}
// Scroll the horizontal (X) axis of the layer visible area over the layer tile map area.
// - layer: Value of 0 or 1.
// - scroll: A value between 0 and 4096.
inline void vera_set_layer_horizontal_scroll(byte layer, word scroll) {
*vera_layer_hscroll_l[layer] = <scroll;
*vera_layer_hscroll_h[layer] = >scroll;
}
// Scroll the vertical (Y) axis of the layer visible area over the layer tile map area.
// - layer: Value of 0 or 1.
// - scroll: A value between 0 and 4096.
inline void vera_set_layer_vertical_scroll(byte layer, word scroll) {
*vera_layer_vscroll_l[layer] = <scroll;
*vera_layer_vscroll_h[layer] = >scroll;
}

View File

@ -14,17 +14,72 @@
void main() {
textcolor(WHITE);
bgcolor(GREEN);
scroll(0); // Scrolling on conio is deactivated, so conio will output beyond the borders of the visible screen.
bgcolor(BLACK);
clrscr();
dword tilebase = vera_get_layer_tilebase_address(1);
// Now we set the tile map width and height.
vera_set_layer_mapbase(0,0x80); // Set the map base to address 0x10000 in VERA VRAM!
vera_set_layer_config(0, vera_get_layer_config(1));
vera_set_layer_tilebase(0, vera_get_layer_tilebase(1));
vera_set_layer_map_width_128(0);
vera_set_layer_map_height_128(0);
dword tilebase = vera_get_layer_tilebase_address(0);
screenlayer(0);
scroll(0); // Scrolling on conio is deactivated, so conio will output beyond the borders of the visible screen.
textcolor(WHITE);
bgcolor(GREEN);
draw_characters(tilebase);
// Enable VSYNC IRQ (also set line bit 8 to 0)
SEI();
*KERNEL_IRQ = &irq_vsync;
*VERA_IEN = VERA_VSYNC;
CLI();
vera_show_layer(0);
while(!kbhit());
vera_hide_layer(0);
textcolor(GREY);
bgcolor(GREEN);
draw_characters(tilebase);
vera_show_layer(0);
screenlayer(1);
textcolor(WHITE);
bgcolor(BLACK);
printf("\n\nthis demo displays the design of the standard x16 commander\n");
printf("character set on the vera layer 0. it's the character set i grew up with :-).\n");
printf("\nthe smooth scrolling is implemented by manipulating the scrolling \n");
printf("registers of layer 0. at each raster line interrupt, \n");
printf("the x and y scrolling registers are manipulated. the cx16 terminal \n");
printf("works on layer 1. when layer 0 is enabled with the scrolling, \n");
printf("it gives a nice background effect. this technique can be used to implement\n");
printf("smooth scrolling backgrounds using tile layouts in games or demos.\n");
textcolor(YELLOW);
printf("\npress a key to continue ...");
while(!kbhit());
screenlayer(0);
vera_hide_layer(0);
textcolor(DARK_GREY);
bgcolor(BLACK);
draw_characters(tilebase);
vera_show_layer(0);
screenlayer(1);
gotoxy(0,20);
}
void draw_characters(dword tilebase) {
dword tilecolumn = tilebase;
dword tilerow = tilebase;
// Now we set the tile map width and height.
vera_set_layer_map_width_128(1);
vera_set_layer_map_height_128(1);
clrscr();
for(byte y:0..15) {
@ -47,15 +102,6 @@ void main() {
}
tilebase += 8*16;
}
// Enable VSYNC IRQ (also set line bit 8 to 0)
SEI();
*KERNEL_IRQ = &irq_vsync;
*VERA_IEN = VERA_VSYNC;
CLI();
}
// X sine index
@ -93,11 +139,8 @@ __interrupt(rom_sys_cx16) void irq_vsync() {
scroll_y = 0;
}
*VERA_L1_HSCROLL_L = <scroll_x;
*VERA_L1_HSCROLL_H = >scroll_x;
*VERA_L1_VSCROLL_L = <scroll_y;
*VERA_L1_VSCROLL_H = >scroll_y;
vera_set_layer_horizontal_scroll(0,(word)scroll_x);
vera_set_layer_vertical_scroll(0,(word)scroll_y);
// Reset the VSYNC interrupt
*VERA_ISR = VERA_VSYNC;