1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-22 16:33:48 +00:00

Fine-tuning the logic.

This commit is contained in:
FlightControl 2021-01-18 07:55:59 +01:00
parent 40bc8e42d6
commit 5daa045271
11 changed files with 690 additions and 1158 deletions

File diff suppressed because it is too large Load Diff

View File

@ -40,49 +40,49 @@ byte vera_layer_backcolor[2] = {BLUE, BLUE};
// Set the configuration of the layer.
// - layer: Value of 0 or 1.
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
void vera_layer_set_config(unsigned byte layer, unsigned byte config);
void vera_layer_set_config(byte layer, byte config);
// Set the configuration of the layer.
// - layer: Value of 0 or 1.
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
unsigned byte vera_layer_get_config(unsigned byte layer);
byte vera_layer_get_config(byte layer);
// Set the map width or height of the layer.
// - layer: Value of 0 or 1.
inline void vera_layer_set_width_32(unsigned byte layer);
inline void vera_layer_set_width_64(unsigned byte layer);
inline void vera_layer_set_width_128(unsigned byte layer);
inline void vera_layer_set_width_256(unsigned byte layer);
inline void vera_layer_set_height_32(unsigned byte layer);
inline void vera_layer_set_height_64(unsigned byte layer);
inline void vera_layer_set_height_128(unsigned byte layer);
inline void vera_layer_set_height_256(unsigned byte layer);
inline void vera_layer_set_width_32(byte layer);
inline void vera_layer_set_width_64(byte layer);
inline void vera_layer_set_width_128(byte layer);
inline void vera_layer_set_width_256(byte layer);
inline void vera_layer_set_height_32(byte layer);
inline void vera_layer_set_height_64(byte layer);
inline void vera_layer_set_height_128(byte layer);
inline void vera_layer_set_height_256(byte layer);
// Enable the layer to be displayed on the screen.
// - layer: 0 or 1.
void vera_layer_show(unsigned byte layer);
void vera_layer_show(byte layer);
// Disable the layer to be displayed on the screen.
// - layer: 0 or 1.
void vera_layer_hide(unsigned byte layer);
void vera_layer_hide(byte layer);
// Is the layer shown on the screen?
// - returns: 1 if layer is displayed on the screen, 0 if not.
unsigned byte vera_layer_is_visible(unsigned byte layer);
byte vera_layer_is_visible(byte layer);
// Set the base of the map for the layer with which the conio will interact.
// - layer: Value of 0 or 1.
// - mapbase: Specifies the base address of the tile map.
// Note that the register only specifies bits 16:9 of the address,
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
void vera_layer_set_mapbase(unsigned byte layer, unsigned byte mapbase);
void vera_layer_set_mapbase(byte layer, byte mapbase);
// Get the base of the map for the layer with which the conio will interact.
// - layer: Value of 0 or 1.
// - return: Returns the base address of the tile map.
// Note that the register is a byte, specifying only bits 16:9 of the address,
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes!
unsigned byte vera_layer_get_mapbase(unsigned byte layer);
byte vera_layer_get_mapbase(byte layer);
// Set the base of the map layer with which the conio will interact.
// - layer: Value of 0 or 1.
@ -121,7 +121,7 @@ void vera_layer_set_tilebase_address(byte layer, dword tilebase_address);
// - return: Specifies the base address of the tile map.
// Note that the register only specifies bits 16:11 of the address,
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
unsigned byte vera_layer_get_tilebase(unsigned byte layer);
byte vera_layer_get_tilebase(byte layer);
// Set the front color for text output. The old front text color setting is returned.
@ -129,35 +129,35 @@ unsigned byte vera_layer_get_tilebase(unsigned byte layer);
// - color: a 4 bit value ( decimal between 0 and 15).
// 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_layer_set_textcolor(unsigned byte layer, unsigned byte color);
byte vera_layer_set_textcolor(byte layer, byte color);
// Get the front color for text output. The old front text color setting is returned.
// - layer: Value of 0 or 1.
// - return: a 4 bit value ( decimal between 0 and 15).
// 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_layer_get_textcolor(unsigned byte layer);
byte vera_layer_get_textcolor(byte layer);
// Set the back color for text output. The old back text color setting is returned.
// - layer: Value of 0 or 1.
// - color: a 4 bit value ( decimal between 0 and 15).
// 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_layer_set_backcolor(unsigned byte layer, unsigned byte color);
byte vera_layer_set_backcolor(byte layer, byte color);
// Get the back color for text output. The old back text color setting is returned.
// - layer: Value of 0 or 1.
// - return: a 4 bit value ( decimal between 0 and 15).
// 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_layer_get_backcolor(unsigned byte layer);
byte vera_layer_get_backcolor(byte layer);
// Get the text and back color for text output in 16 color mode.
// - layer: Value of 0 or 1.
// - return: an 8 bit value with bit 7:4 containing the back color and bit 3:0 containing the front color.
// 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_layer_get_color(unsigned byte layer);
byte vera_layer_get_color(byte layer);
// Scroll the horizontal (X) axis of the layer visible area over the layer tile map area.
// - layer: Value of 0 or 1.

View File

@ -71,7 +71,7 @@ void conio_x16_init() {
// Position cursor at current line
char * const BASIC_CURSOR_LINE = 0xD6;
char line = *BASIC_CURSOR_LINE;
vera_layer_mode_tile(1,0x00000,0x0F800,128,64,8,8,1);
vera_layer_mode_tile(1,(dword)0x00000,(dword)0x0F800,128,64,8,8,1);
screensize(&conio_screen_width, &conio_screen_height);
screenlayer(1);
vera_layer_set_textcolor(1, WHITE);

View File

@ -40,59 +40,59 @@ void vera_vram_address1(dword bankaddr, byte incr) {
// Set the configuration of the layer.
// - layer: Value of 0 or 1.
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
void vera_layer_set_config(char layer, char config) {
void vera_layer_set_config(byte layer, byte config) {
layer &= $1;
char* addr = vera_layer_config[layer];
byte* addr = vera_layer_config[layer];
*addr = config;
}
// Set the configuration of the layer.
// - layer: Value of 0 or 1.
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
char vera_layer_get_config(char layer) {
char* config = vera_layer_config[layer];
byte vera_layer_get_config(byte layer) {
byte* config = vera_layer_config[layer];
return *config;
}
// Set the map width or height of the layer.
// - layer: Value of 0 or 1.
inline void vera_layer_set_width_32(unsigned byte layer) {
inline void vera_layer_set_width_32(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_WIDTH_MASK;
*addr |= VERA_LAYER_WIDTH_32;
}
inline void vera_layer_set_width_64(unsigned byte layer) {
inline void vera_layer_set_width_64(byte layer) {
byte* addr = vera_layer_config[layer];
//*addr &= (~VERA_CONFIG_WIDTH_MASK) | VERA_CONFIG_WIDTH_64;
*addr &= ~VERA_LAYER_WIDTH_MASK;
*addr |= VERA_LAYER_WIDTH_64;
}
inline void vera_layer_set_width_128(unsigned byte layer) {
inline void vera_layer_set_width_128(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_WIDTH_MASK;
*addr |= VERA_LAYER_WIDTH_128;
}
inline void vera_layer_set_width_256(unsigned byte layer) {
inline void vera_layer_set_width_256(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_WIDTH_MASK;
*addr |= VERA_LAYER_WIDTH_256;
}
inline void vera_layer_set_height_32(unsigned byte layer) {
inline void vera_layer_set_height_32(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_HEIGHT_MASK;
*addr |= VERA_LAYER_HEIGHT_32;
}
inline void vera_layer_set_height_64(unsigned byte layer) {
inline void vera_layer_set_height_64(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_HEIGHT_MASK;
*addr |= VERA_LAYER_HEIGHT_64;
}
inline void vera_layer_set_height_128(unsigned byte layer) {
inline void vera_layer_set_height_128(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_HEIGHT_MASK;
*addr |= VERA_LAYER_HEIGHT_128;
}
inline void vera_layer_set_height_256(unsigned byte layer) {
inline void vera_layer_set_height_256(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_HEIGHT_MASK;
*addr |= VERA_LAYER_HEIGHT_256;
@ -100,13 +100,13 @@ inline void vera_layer_set_height_256(unsigned byte layer) {
// Get the map width or height of the layer.
// - layer: Value of 0 or 1.
word vera_layer_get_width(unsigned byte layer) {
word vera_layer_get_width(byte layer) {
byte* config = vera_layer_config[layer];
byte mask = (byte)VERA_LAYER_WIDTH_MASK;
return VERA_LAYER_WIDTH[ (*config & mask) >> 4];
}
word vera_layer_get_height(unsigned byte layer) {
word vera_layer_get_height(byte layer) {
byte* config = vera_layer_config[layer];
byte mask = VERA_LAYER_HEIGHT_MASK;
return VERA_LAYER_HEIGHT[ (*config & mask) >> 6];
@ -114,22 +114,22 @@ word vera_layer_get_height(unsigned byte layer) {
// Set the color depth of the layer in terms of bit per pixel (BPP) of the tile base.
// - layer: Value of 0 or 1.
inline void vera_layer_set_color_depth_1BPP(unsigned byte layer) {
inline void vera_layer_set_color_depth_1BPP(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
*addr |= VERA_LAYER_COLOR_DEPTH_1BPP;
}
inline void vera_layer_set_color_depth_2BPP(unsigned byte layer) {
inline void vera_layer_set_color_depth_2BPP(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
*addr |= VERA_LAYER_COLOR_DEPTH_2BPP;
}
inline void vera_layer_set_color_depth_4BPP(unsigned byte layer) {
inline void vera_layer_set_color_depth_4BPP(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
*addr |= VERA_LAYER_COLOR_DEPTH_4BPP;
}
inline void vera_layer_set_color_depth_8BPP(unsigned byte layer) {
inline void vera_layer_set_color_depth_8BPP(byte layer) {
byte* addr = vera_layer_config[layer];
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
*addr |= VERA_LAYER_COLOR_DEPTH_8BPP;
@ -138,7 +138,7 @@ inline void vera_layer_set_color_depth_8BPP(unsigned byte layer) {
// Get the map width or height of the layer.
// - layer: Value of 0 or 1.
// - return: 1, 2, 4 or 8.
word vera_layer_get_color_depth(unsigned byte layer) {
word vera_layer_get_color_depth(byte layer) {
byte* config = vera_layer_config[layer];
byte mask = (byte)VERA_LAYER_COLOR_DEPTH_MASK;
return VERA_LAYER_COLOR_DEPTH[(*config & mask)];
@ -146,21 +146,21 @@ word vera_layer_get_color_depth(unsigned byte layer) {
// Enable the layer to be displayed on the screen.
// - layer: 0 or 1.
inline void vera_layer_show(char layer) {
inline void vera_layer_show(byte layer) {
*VERA_DC_VIDEO |= vera_layer_enable[layer];
}
// Disable the layer to be displayed on the screen.
// - layer: 0 or 1.
inline void vera_layer_hide(char layer) {
inline void vera_layer_hide(byte layer) {
*VERA_DC_VIDEO &= ~vera_layer_enable[layer];
}
// Is the layer shown on the screen?
// - returns: 1 if layer is displayed on the screen, 0 if not.
char vera_layer_is_visible(char layer) {
inline byte vera_layer_is_visible(byte layer) {
return *VERA_DC_VIDEO & vera_layer_enable[layer];
}
@ -169,8 +169,8 @@ char vera_layer_is_visible(char layer) {
// - mapbase: Specifies the base address of the tile map.
// Note that the register only specifies bits 16:9 of the address,
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
void vera_layer_set_mapbase(unsigned byte layer, unsigned byte mapbase) {
unsigned byte* addr = vera_layer_mapbase[layer];
void vera_layer_set_mapbase(byte layer, byte mapbase) {
byte* addr = vera_layer_mapbase[layer];
*addr = mapbase;
}
@ -223,8 +223,8 @@ word vera_layer_get_mapbase_offset(byte layer) {
// - return: Returns the base address of the tile map.
// Note that the register is a byte, specifying only bits 16:9 of the address,
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
unsigned byte vera_layer_get_mapbase(unsigned byte layer) {
unsigned byte* mapbase = vera_layer_mapbase[layer];
byte vera_layer_get_mapbase(byte layer) {
byte* mapbase = vera_layer_mapbase[layer];
return *mapbase;
}
@ -233,8 +233,8 @@ unsigned byte vera_layer_get_mapbase(unsigned byte layer) {
// - tilebase: Specifies the base address of the tile map.
// Note that the register only specifies bits 16:11 of the address,
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
void vera_layer_set_tilebase(unsigned byte layer, unsigned byte tilebase) {
unsigned byte* addr = vera_layer_tilebase[layer];
void vera_layer_set_tilebase(byte layer, byte tilebase) {
byte* addr = vera_layer_tilebase[layer];
*addr = tilebase;
}
@ -296,8 +296,8 @@ dword vera_layer_get_tilebase_address(byte layer) {
// - color: a 4 bit value ( decimal between 0 and 15).
// 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_layer_set_textcolor(unsigned byte layer, unsigned byte color) {
unsigned byte old = vera_layer_textcolor[layer];
byte vera_layer_set_textcolor(byte layer, byte color) {
byte old = vera_layer_textcolor[layer];
vera_layer_textcolor[layer] = color;
return old;
}
@ -307,7 +307,7 @@ unsigned byte vera_layer_set_textcolor(unsigned byte layer, unsigned byte color)
// - return: a 4 bit value ( decimal between 0 and 15).
// 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_layer_get_textcolor(unsigned byte layer) {
byte vera_layer_get_textcolor(byte layer) {
layer &= $1;
return vera_layer_textcolor[layer];
}
@ -317,9 +317,9 @@ unsigned byte vera_layer_get_textcolor(unsigned byte layer) {
// - color: a 4 bit value ( decimal between 0 and 15).
// 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_layer_set_backcolor(unsigned byte layer, unsigned byte color) {
byte vera_layer_set_backcolor(byte layer, byte color) {
layer &= $1;
unsigned byte old = vera_layer_backcolor[layer];
byte old = vera_layer_backcolor[layer];
vera_layer_backcolor[layer] = color;
return old;
}
@ -329,7 +329,7 @@ unsigned byte vera_layer_set_backcolor(unsigned byte layer, unsigned byte color)
// - return: a 4 bit value ( decimal between 0 and 15).
// 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_layer_get_backcolor(unsigned byte layer) {
byte vera_layer_get_backcolor(byte layer) {
layer &= $1;
return vera_layer_backcolor[layer];
}
@ -339,7 +339,7 @@ unsigned byte vera_layer_get_backcolor(unsigned byte layer) {
// - return: an 8 bit value with bit 7:4 containing the back color and bit 3:0 containing the front color.
// 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_layer_get_color(unsigned byte layer) {
byte vera_layer_get_color(byte layer) {
layer &= $1;
return ((vera_layer_backcolor[layer] << 4) | vera_layer_textcolor[layer]);
}

View File

@ -4,6 +4,7 @@
void main() {
dword value = 0xff446677;
clrscr();
printf("77 = %x\n", <(<(value)) );
printf("66 = %x\n", >(<(value)) );
printf("44 = %x\n", <(>(value)) );

View File

@ -0,0 +1,13 @@
#include <printf.h>
void main() {
word value = 0xf801;
dword dw_value[2] = {0,0};
for(word t:0..1) {
dw_value[t] = 0xf800;
}
clrscr();
printf("f801 = %x\n", dw_value[1] );
}

View File

@ -19,15 +19,9 @@ void main() {
bgcolor(BLACK);
clrscr();
// Now we set the tile map width and height.
// vera_layer_set_mapbase(0,0x80); // Set the map base to address 0x10000 in VERA VRAM!
// vera_layer_set_config(0, vera_layer_get_config(1));
// vera_layer_set_tilebase(0, vera_layer_get_tilebase(1));
// vera_layer_set_width_128(0);
// vera_layer_set_height_128(0);
dword tilebase = vera_layer_get_tilebase_address(1);
vera_mode_tile(0, 0x10000, 0xF800, 128, 128, 8, 8, 1);
vera_layer_mode_tile(0, 0x10000, tilebase, 128, 128, 8, 8, 1);
screenlayer(0);
scroll(0); // Scrolling on conio is deactivated, so conio will output beyond the borders of the visible screen.

View File

@ -18,7 +18,7 @@ void main() {
bgcolor(BLACK);
clrscr();
vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 2);
vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 2);
byte tiles[64] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
@ -58,7 +58,7 @@ void main() {
vera_layer_show(0);
gotoxy(0,40);
gotoxy(0,50);
printf("vera in tile mode 8 x 8, color depth 2 bits per pixel.\n");
printf("in this mode, tiles are 8 pixels wide and 8 pixels tall.\n");

View File

@ -18,7 +18,7 @@ void main() {
bgcolor(BLACK);
clrscr();
vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 16, 16, 4);
vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 16, 16, 4);
byte tiles[2048] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -207,7 +207,7 @@ void main() {
vera_layer_show(0);
gotoxy(0,46);
gotoxy(0,50);
printf("vera in tile mode 16 x 16, color depth 4 bits per pixel.\n");
printf("in this mode, tiles are 16 pixels wide and 16 pixels tall.\n");

View File

@ -17,7 +17,7 @@ void main() {
bgcolor(BLACK);
clrscr();
vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 4);
vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 4);
byte tiles[512] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -56,8 +56,6 @@ void main() {
memcpy_to_vram(1, 0x4000, tiles, 512);
//vera_tile_area(byte layer, word tileindex, byte x, byte y, byte w, byte h, byte hflip, byte vflip, byte offset)
vera_tile_area(0, 0, 0, 0, 80, 60, 0, 0, 0);
word tile = 0;
@ -110,7 +108,7 @@ void main() {
vera_layer_show(0);
gotoxy(0,46);
gotoxy(0,50);
printf("vera in tile mode 8 x 8, color depth 4 bits per pixel.\n");
printf("in this mode, tiles are 8 pixels wide and 8 pixels tall.\n");

View File

@ -17,7 +17,7 @@ void main() {
bgcolor(BLACK);
clrscr();
vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 8);
vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 8);
byte tiles[64] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -75,7 +75,7 @@ void main() {
vera_layer_show(0);
gotoxy(0,46);
gotoxy(0,50);
printf("vera in tile mode 8 x 8, color depth 8 bits per pixel.\n");
printf("in this mode, tiles are 8 pixels wide and 8 pixels tall.\n");