mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-28 16:31:36 +00:00
fixed much code, working on 16x16 8bit tile mode.
There is an error in the compiler i think which i need to communicate to Jesper.
This commit is contained in:
parent
d45e58a1be
commit
a5b10d962f
@ -3929,3 +3929,59 @@ NO_SYNTHESIS
|
||||
//FRAGMENT pbuc1_derefidx_vbuz1=vbuaa
|
||||
ldy {z1}
|
||||
sta {c1},y
|
||||
//FRAGMENT vbuz1=vbuz1_plus_2
|
||||
lda {z1}
|
||||
clc
|
||||
adc #2
|
||||
sta {z1}
|
||||
//FRAGMENT vbuxx=vbuxx_plus_2
|
||||
inx
|
||||
inx
|
||||
//FRAGMENT pbuc1_derefidx_vbuz1=pbuc1_derefidx_vbuz1_plus_1
|
||||
ldy {z1}
|
||||
lda {c1},y
|
||||
inc
|
||||
sta {c1},y
|
||||
//FRAGMENT pbuc1_derefidx_vbuaa=pbuc1_derefidx_vbuaa_plus_1
|
||||
tay
|
||||
lda {c1},y
|
||||
inc
|
||||
sta {c1},y
|
||||
//FRAGMENT pbuc1_derefidx_vbuxx=pbuc1_derefidx_vbuxx_plus_1
|
||||
lda {c1},x
|
||||
inc
|
||||
sta {c1},x
|
||||
//FRAGMENT pbuc1_derefidx_vbuyy=pbuc1_derefidx_vbuyy_plus_1
|
||||
lda {c1},y
|
||||
inc
|
||||
sta {c1},y
|
||||
//FRAGMENT vwuz1=vwuz1_plus_vwuc1
|
||||
clc
|
||||
lda {z1}
|
||||
adc #<{c1}
|
||||
sta {z1}
|
||||
lda {z1}+1
|
||||
adc #>{c1}
|
||||
sta {z1}+1
|
||||
//FRAGMENT vbuyy_neq_0_then_la1
|
||||
cpy #0
|
||||
bne {la1}
|
||||
//FRAGMENT vbuz1=vbuc1_bor_vbuaa
|
||||
ora #{c1}
|
||||
sta {z1}
|
||||
//FRAGMENT vbuaa=vbuc1_bor_vbuaa
|
||||
ora #{c1}
|
||||
//FRAGMENT vbuxx=vbuc1_bor_vbuaa
|
||||
ora #{c1}
|
||||
tax
|
||||
//FRAGMENT vbuyy=vbuc1_bor_vbuaa
|
||||
ora #{c1}
|
||||
tay
|
||||
//FRAGMENT vbuyy=vbuxx_bor_vbuaa
|
||||
stx $ff
|
||||
ora $ff
|
||||
tay
|
||||
//FRAGMENT _deref_pduc1=vbuc2
|
||||
NO_SYNTHESIS
|
||||
//FRAGMENT _deref_pduc1=vbsc2
|
||||
NO_SYNTHESIS
|
||||
|
@ -184,7 +184,7 @@ byte const VERA_TILEBASE_WIDTH_MASK = 0x01;
|
||||
byte const VERA_TILEBASE_HEIGHT_8 = 0x00;
|
||||
byte const VERA_TILEBASE_HEIGHT_16 = 0x02;
|
||||
byte const VERA_TILEBASE_HEIGHT_MASK = 0x02;
|
||||
byte const VERA_TILEBASE_MASK = 0xfC;
|
||||
byte const VERA_LAYER_TILEBASE_MASK = 0xfC;
|
||||
// Bit 0: Tile Width (0:8 pixels, 1:16 pixels)
|
||||
char * const VERA_L0_TILEBASE = 0x9f2f;
|
||||
// $9F30 L0_HSCROLL_L Layer 0 H-Scroll (7:0)
|
||||
|
@ -3,70 +3,125 @@
|
||||
|
||||
// Author: Sven Van de Velde
|
||||
|
||||
#include <cx16-vera.h>
|
||||
|
||||
// --- VERA function encapsulation ---
|
||||
|
||||
__ma word vera_mapbase_offset[2] = {0,0};
|
||||
__ma byte vera_mapbase_bank[2] = {0,0};
|
||||
__ma dword vera_mapbase_address[2] = {0,0};
|
||||
|
||||
word vera_tilebase_offset[2] = {0,0};
|
||||
byte vera_tilebase_bank[2] = {0,0};
|
||||
dword vera_tilebase_address[2] = {0,0};
|
||||
|
||||
byte vera_layer_rowshift[2] = {0,0};
|
||||
word vera_layer_rowskip[2] = {0,0};
|
||||
|
||||
const byte vera_layer_hflip[2] = {0,0x04};
|
||||
const byte vera_layer_vflip[2] = {0,0x08};
|
||||
|
||||
|
||||
byte* vera_layer_config[2] = {VERA_L0_CONFIG, VERA_L1_CONFIG};
|
||||
byte vera_layer_enable[2] = { VERA_LAYER0_ENABLE, VERA_LAYER1_ENABLE };
|
||||
|
||||
byte* vera_layer_mapbase[2] = {VERA_L0_MAPBASE, VERA_L1_MAPBASE};
|
||||
byte* vera_layer_tilebase[2] = {VERA_L0_TILEBASE, VERA_L1_TILEBASE};
|
||||
byte* vera_layer_vscroll_l[2] = {VERA_L0_VSCROLL_L, VERA_L1_VSCROLL_L};
|
||||
byte* vera_layer_vscroll_h[2] = {VERA_L0_VSCROLL_H, VERA_L1_VSCROLL_H};
|
||||
byte* vera_layer_hscroll_l[2] = {VERA_L0_HSCROLL_L, VERA_L1_HSCROLL_L};
|
||||
byte* vera_layer_hscroll_h[2] = {VERA_L0_HSCROLL_H, VERA_L1_HSCROLL_H};
|
||||
|
||||
byte vera_layer_textcolor[2] = {WHITE, WHITE};
|
||||
byte vera_layer_backcolor[2] = {BLUE, BLUE};
|
||||
|
||||
// --- VERA LAYERS ---
|
||||
|
||||
// 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_set_layer_config(unsigned byte layer, unsigned byte config);
|
||||
void vera_layer_set_config(unsigned byte layer, unsigned 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_get_layer_config(unsigned byte layer);
|
||||
unsigned byte vera_layer_get_config(unsigned byte layer);
|
||||
|
||||
// Set the map width or height of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_set_layer_map_width_32(unsigned byte layer);
|
||||
inline void vera_set_layer_map_width_64(unsigned byte layer);
|
||||
inline void vera_set_layer_map_width_128(unsigned byte layer);
|
||||
inline void vera_set_layer_map_width_256(unsigned byte layer);
|
||||
inline void vera_set_layer_map_height_32(unsigned byte layer);
|
||||
inline void vera_set_layer_map_height_64(unsigned byte layer);
|
||||
inline void vera_set_layer_map_height_128(unsigned byte layer);
|
||||
inline void vera_set_layer_map_height_256(unsigned byte layer);
|
||||
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);
|
||||
|
||||
// Enable the layer to be displayed on the screen.
|
||||
// - layer: 0 or 1.
|
||||
void vera_show_layer(unsigned byte layer);
|
||||
void vera_layer_show(unsigned byte layer);
|
||||
|
||||
// Disable the layer to be displayed on the screen.
|
||||
// - layer: 0 or 1.
|
||||
void vera_hide_layer(unsigned byte layer);
|
||||
void vera_layer_hide(unsigned byte layer);
|
||||
|
||||
// Is the layer shown on the screen?
|
||||
// - returns: 1 if layer is displayed on the screen, 0 if not.
|
||||
unsigned byte vera_is_layer_shown(unsigned byte layer);
|
||||
unsigned byte vera_layer_is_visible(unsigned 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_set_layer_mapbase(unsigned byte layer, unsigned byte mapbase);
|
||||
void vera_layer_set_mapbase(unsigned byte layer, unsigned 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_get_layer_mapbase(unsigned byte layer);
|
||||
unsigned byte vera_layer_get_mapbase(unsigned byte layer);
|
||||
|
||||
// Set the base of the map layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - dw_mapbase: a dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective mapbase vera register.
|
||||
// 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_address(byte layer, dword dw_mapbase);
|
||||
|
||||
// Get the map base address of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Specifies the map base address of the layer, which is returned as a dword.
|
||||
// Note that the register only specifies bits 16:9 of the 17 bit address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes!
|
||||
dword vera_layer_get_mapbase_address(byte layer);
|
||||
|
||||
// Set the base of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - 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_set_layer_tilebase(unsigned byte layer, unsigned byte tilebase);
|
||||
void vera_layer_set_tilebase(byte layer, byte tilebase);
|
||||
|
||||
// Set the base of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - dw_tilebase: a dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective tilebase vera register.
|
||||
// Note that the resulting vera register holds 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_address(byte layer, dword dw_tilebase);
|
||||
|
||||
// Get the base of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - 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_get_layer_tilebase(unsigned byte layer);
|
||||
unsigned byte vera_layer_get_tilebase(unsigned byte layer);
|
||||
|
||||
|
||||
// Set the front color for text output. The old front text color setting is returned.
|
||||
@ -74,42 +129,44 @@ unsigned byte vera_get_layer_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_set_layer_textcolor(unsigned byte layer, unsigned byte color);
|
||||
unsigned byte vera_layer_set_textcolor(unsigned byte layer, unsigned 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_get_layer_textcolor(unsigned byte layer);
|
||||
unsigned byte vera_layer_get_textcolor(unsigned 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_set_layer_backcolor(unsigned byte layer, unsigned byte color);
|
||||
unsigned byte vera_layer_set_backcolor(unsigned byte layer, unsigned 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_get_layer_backcolor(unsigned byte layer);
|
||||
unsigned byte vera_layer_get_backcolor(unsigned 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_get_layer_color(unsigned byte layer);
|
||||
unsigned byte vera_layer_get_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);
|
||||
inline void vera_layer_set_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);
|
||||
inline void vera_layer_set_vertical_scroll(byte layer, word scroll);
|
||||
|
||||
void vera_layer_mode_tile(byte layer, dword mapbase_address, dword dw_tilebase, word mapwidth, word mapheight, byte tilewidth, byte tileheight, byte color_depth );
|
||||
|
@ -1,6 +1,7 @@
|
||||
// CX16 conio.h implementation
|
||||
#include <conio.h>
|
||||
#include <cx16.h>
|
||||
#include <veralib.h>
|
||||
|
||||
// The screen width
|
||||
#define CONIO_WIDTH conio_screen_width
|
||||
@ -25,6 +26,43 @@ const char CONIO_TEXTCOLOR_DEFAULT = WHITE;
|
||||
// The default back color
|
||||
const char CONIO_BACKCOLOR_DEFAULT = BLUE;
|
||||
|
||||
|
||||
// This requires the following constants to be defined
|
||||
// - CONIO_WIDTH - The screen width
|
||||
// - CONIO_HEIGHT - The screen height
|
||||
// - CONIO_SCREEN_TEXT - The text screen address
|
||||
// - CONIO_SCREEN_COLORS - The color screen address
|
||||
// - CONIO_TEXTCOLOR_DEFAULT - The default text color
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// The number of bytes on the screen
|
||||
#define CONIO_BYTES CONIO_HEIGHT*CONIO_WIDTH
|
||||
|
||||
// The current cursor x-position
|
||||
unsigned byte conio_cursor_x[2] = {0,0};
|
||||
// The current cursor y-position
|
||||
unsigned byte conio_cursor_y[2] = {0,0};
|
||||
// The current text cursor line start
|
||||
unsigned word conio_line_text[2] = {0x0000,0x0000};
|
||||
// Is a cursor whown when waiting for input (0: no, other: yes)
|
||||
__ma unsigned byte conio_display_cursor = 0;
|
||||
// Is scrolling enabled when outputting beyond the end of the screen (1: yes, 0: no).
|
||||
// If disabled the cursor just moves back to (0,0) instead
|
||||
unsigned byte conio_scroll_enable[2] = {1,1};
|
||||
// Variable holding the screen width;
|
||||
__ma unsigned byte conio_screen_width = 0;
|
||||
// Variable holding the screen height;
|
||||
__ma unsigned byte conio_screen_height = 0;
|
||||
// Variable holding the screen layer on the VERA card with which conio interacts;
|
||||
__ma unsigned byte conio_screen_layer = 1;
|
||||
|
||||
// Variables holding the current map width and map height of the layer.
|
||||
__ma word conio_width = 0;
|
||||
__ma word conio_height = 0;
|
||||
__ma byte conio_rowshift = 0;
|
||||
__ma word conio_rowskip = 0;
|
||||
|
||||
// Initializer for conio.h on X16 Commander.
|
||||
#pragma constructor_for(conio_x16_init, cputc, clrscr, cscroll)
|
||||
|
||||
@ -33,12 +71,21 @@ 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_mapbase_address[1] = 0x00000;
|
||||
vera_mapbase_offset[1] = 0x0000;
|
||||
vera_mapbase_bank[1] = 0x00;
|
||||
vera_tilebase_address[1] = 0x0f800;
|
||||
vera_tilebase_bank[1] = 0x00;
|
||||
vera_tilebase_offset[1] = 0xf800;
|
||||
vera_layer_rowskip[1] = 256;
|
||||
vera_layer_rowshift[1] = 8;
|
||||
screensize(&conio_screen_width, &conio_screen_height);
|
||||
screenlayer(1);
|
||||
vera_set_layer_textcolor(1, WHITE);
|
||||
vera_set_layer_backcolor(1, BLUE);
|
||||
vera_set_layer_mapbase(0,0x20);
|
||||
vera_set_layer_mapbase(1,0x00);
|
||||
vera_layer_set_textcolor(1, WHITE);
|
||||
vera_layer_set_backcolor(1, BLUE);
|
||||
vera_layer_set_mapbase(0,0x20);
|
||||
vera_layer_set_mapbase(1,0x00);
|
||||
if(line>=CONIO_HEIGHT) line=CONIO_HEIGHT-1;
|
||||
gotoxy(0, line);
|
||||
}
|
||||
@ -87,46 +134,10 @@ unsigned char kbhit(void) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
// This requires the following constants to be defined
|
||||
// - CONIO_WIDTH - The screen width
|
||||
// - CONIO_HEIGHT - The screen height
|
||||
// - CONIO_SCREEN_TEXT - The text screen address
|
||||
// - CONIO_SCREEN_COLORS - The color screen address
|
||||
// - CONIO_TEXTCOLOR_DEFAULT - The default text color
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// The number of bytes on the screen
|
||||
#define CONIO_BYTES CONIO_HEIGHT*CONIO_WIDTH
|
||||
|
||||
// The current cursor x-position
|
||||
unsigned byte conio_cursor_x[2] = {0,0};
|
||||
// The current cursor y-position
|
||||
unsigned byte conio_cursor_y[2] = {0,0};
|
||||
// The current text cursor line start
|
||||
unsigned word conio_line_text[2] = {0x0000,0x0000};
|
||||
// Is a cursor whown when waiting for input (0: no, other: yes)
|
||||
__ma unsigned byte conio_display_cursor = 0;
|
||||
// Is scrolling enabled when outputting beyond the end of the screen (1: yes, 0: no).
|
||||
// If disabled the cursor just moves back to (0,0) instead
|
||||
unsigned byte conio_scroll_enable[2] = {1,1};
|
||||
// Variable holding the screen width;
|
||||
__ma unsigned byte conio_screen_width = 0;
|
||||
// Variable holding the screen height;
|
||||
__ma unsigned byte conio_screen_height = 0;
|
||||
// Variable holding the screen layer on the VERA card with which conio interacts;
|
||||
__ma unsigned byte conio_screen_layer = 1;
|
||||
|
||||
// Variables holding the current map width and map height of the layer.
|
||||
__ma word conio_width = 0;
|
||||
__ma word conio_height = 0;
|
||||
__ma byte conio_skip = 0;
|
||||
|
||||
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
|
||||
void clrscr(void) {
|
||||
char* line_text = CONIO_SCREEN_TEXT;
|
||||
word skip = (word)((word)1<<conio_skip);
|
||||
char color = ( vera_get_layer_backcolor(conio_screen_layer) << 4 ) | vera_get_layer_textcolor(conio_screen_layer);
|
||||
char color = ( vera_layer_get_backcolor(conio_screen_layer) << 4 ) | vera_layer_get_textcolor(conio_screen_layer);
|
||||
for( char l=0;l<conio_height; l++ ) {
|
||||
char *ch = line_text;
|
||||
// Select DATA0
|
||||
@ -139,7 +150,7 @@ void clrscr(void) {
|
||||
*VERA_DATA0 = ' ';
|
||||
*VERA_DATA0 = color;
|
||||
}
|
||||
line_text += skip;
|
||||
line_text += conio_rowskip;
|
||||
}
|
||||
conio_cursor_x[conio_screen_layer] = 0;
|
||||
conio_cursor_y[conio_screen_layer] = 0;
|
||||
@ -152,7 +163,7 @@ void gotoxy(unsigned byte x, unsigned byte y) {
|
||||
if(x>=CONIO_WIDTH) x = 0;
|
||||
conio_cursor_x[conio_screen_layer] = x;
|
||||
conio_cursor_y[conio_screen_layer] = y;
|
||||
unsigned int line_offset = (unsigned int)y << conio_skip;
|
||||
unsigned int line_offset = (unsigned int)y << conio_rowshift;
|
||||
conio_line_text[conio_screen_layer] = line_offset;
|
||||
}
|
||||
|
||||
@ -193,7 +204,7 @@ inline unsigned byte wherey(void) {
|
||||
// Output one character at the current cursor position
|
||||
// Moves the cursor forward. Scrolls the entire screen if needed
|
||||
void cputc(char c) {
|
||||
char color = vera_get_layer_color( conio_screen_layer);
|
||||
char color = vera_layer_get_color( conio_screen_layer);
|
||||
char* conio_addr = CONIO_SCREEN_TEXT + conio_line_text[conio_screen_layer];
|
||||
|
||||
conio_addr += conio_cursor_x[conio_screen_layer] << 1;
|
||||
@ -225,7 +236,7 @@ void cputc(char c) {
|
||||
void cputln() {
|
||||
// TODO: This needs to be optimized! other variations don't compile because of sections not available!
|
||||
word temp = conio_line_text[conio_screen_layer];
|
||||
temp += (word)((word)1<<conio_skip);
|
||||
temp += conio_rowskip;
|
||||
conio_line_text[conio_screen_layer] = temp;
|
||||
conio_cursor_x[conio_screen_layer] = 0;
|
||||
conio_cursor_y[conio_screen_layer]++;
|
||||
@ -240,7 +251,7 @@ void clearline() {
|
||||
*VERA_ADDRX_L = <addr;
|
||||
*VERA_ADDRX_M = >addr;
|
||||
*VERA_ADDRX_H = VERA_INC_1;
|
||||
char color = vera_get_layer_color( conio_screen_layer);
|
||||
char color = vera_layer_get_color( conio_screen_layer);
|
||||
for( unsigned int c=0;c<CONIO_WIDTH; c++ ) {
|
||||
// Set data
|
||||
*VERA_DATA0 = ' ';
|
||||
@ -255,9 +266,9 @@ void insertdown() {
|
||||
cy -= 1;
|
||||
unsigned byte width = CONIO_WIDTH * 2;
|
||||
for(unsigned byte i=cy; i>0; i--) {
|
||||
unsigned int line = (conio_cursor_y[conio_screen_layer] + i - 1) << conio_skip;
|
||||
unsigned int line = (conio_cursor_y[conio_screen_layer] + i - 1) << conio_rowshift;
|
||||
unsigned char* start = CONIO_SCREEN_TEXT + line;
|
||||
memcpy_in_vram(0, start+((word)1<<conio_skip), VERA_INC_1, 0, start, VERA_INC_1, width);
|
||||
memcpy_in_vram(0, start+conio_rowskip, VERA_INC_1, 0, start, VERA_INC_1, width);
|
||||
}
|
||||
clearline();
|
||||
}
|
||||
@ -267,9 +278,9 @@ void insertup() {
|
||||
unsigned byte cy = conio_cursor_y[conio_screen_layer];
|
||||
unsigned byte width = CONIO_WIDTH * 2;
|
||||
for(unsigned byte i=1; i<=cy; i++) {
|
||||
unsigned int line = (i-1) << conio_skip;
|
||||
unsigned int line = (i-1) << conio_rowshift;
|
||||
unsigned char* start = CONIO_SCREEN_TEXT + line;
|
||||
memcpy_in_vram(0, start, VERA_INC_1, 0, start+((word)1<<conio_skip), VERA_INC_1, width);
|
||||
memcpy_in_vram(0, start, VERA_INC_1, 0, start+conio_rowskip, VERA_INC_1, width);
|
||||
}
|
||||
clearline();
|
||||
}
|
||||
@ -335,15 +346,13 @@ unsigned byte scroll(unsigned byte onoff) {
|
||||
// Set the layer with which the conio will interact.
|
||||
// - layer: value of 0 or 1.
|
||||
void screenlayer(unsigned byte layer) {
|
||||
layer &= $1;
|
||||
conio_screen_layer = layer;
|
||||
unsigned byte addr = vera_get_layer_mapbase(layer);
|
||||
unsigned int addr_i = addr << 1;
|
||||
CONIO_SCREEN_BANK = >addr_i;
|
||||
CONIO_SCREEN_TEXT = addr_i << 8;
|
||||
conio_width = vera_get_layer_map_width(conio_screen_layer);
|
||||
conio_skip = (byte)(conio_width >> 4);
|
||||
conio_height = vera_get_layer_map_height(conio_screen_layer);
|
||||
CONIO_SCREEN_BANK = vera_layer_get_mapbase_bank(conio_screen_layer);
|
||||
CONIO_SCREEN_TEXT = vera_layer_get_mapbase_offset(conio_screen_layer);
|
||||
conio_width = vera_layer_get_width(conio_screen_layer);
|
||||
conio_rowshift = vera_layer_get_rowshift(conio_screen_layer);
|
||||
conio_rowskip = vera_layer_get_rowskip(conio_screen_layer);
|
||||
conio_height = vera_layer_get_height(conio_screen_layer);
|
||||
}
|
||||
|
||||
|
||||
@ -352,7 +361,7 @@ void screenlayer(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.
|
||||
inline char textcolor(char color) {
|
||||
return vera_set_layer_textcolor(conio_screen_layer, color);
|
||||
return vera_layer_set_textcolor(conio_screen_layer, color);
|
||||
}
|
||||
|
||||
// Set the back color for text output. The old back text color setting is returned.
|
||||
@ -360,7 +369,7 @@ inline char textcolor(char color) {
|
||||
// This will only work when the VERA is in 16 color mode!
|
||||
// Note that on the VERA, the transparent color has value 0.
|
||||
inline char bgcolor(char color) {
|
||||
return vera_set_layer_backcolor(conio_screen_layer, color);
|
||||
return vera_layer_set_backcolor(conio_screen_layer, color);
|
||||
}
|
||||
|
||||
// Set the color for the border. The old color setting is returned.
|
||||
|
@ -10,32 +10,6 @@
|
||||
|
||||
// --- VERA layer management ---
|
||||
|
||||
word vera_mapbase_word[2] = {0,0};
|
||||
byte vera_mapbase_bank[2] = {0,0};
|
||||
dword vera_mapbase_dword[2] = {0,0};
|
||||
|
||||
word vera_tilebase_word[2] = {0,0};
|
||||
byte vera_tilebase_bank[2] = {0,0};
|
||||
dword vera_tilebase_dword[2] = {0,0};
|
||||
|
||||
byte vera_row_shift[2] = {0,0};
|
||||
|
||||
const byte vera_layer_hflip[2] = {0,0x04};
|
||||
const byte vera_layer_vflip[2] = {0,0x08};
|
||||
|
||||
|
||||
byte* vera_layer_config[2] = {VERA_L0_CONFIG, VERA_L1_CONFIG};
|
||||
byte vera_layer_enable[2] = { VERA_LAYER0_ENABLE, VERA_LAYER1_ENABLE };
|
||||
|
||||
byte* vera_layer_mapbase[2] = {VERA_L0_MAPBASE, VERA_L1_MAPBASE};
|
||||
byte* vera_layer_tilebase[2] = {VERA_L0_TILEBASE, VERA_L1_TILEBASE};
|
||||
byte* vera_layer_vscroll_l[2] = {VERA_L0_VSCROLL_L, VERA_L1_VSCROLL_L};
|
||||
byte* vera_layer_vscroll_h[2] = {VERA_L0_VSCROLL_H, VERA_L1_VSCROLL_H};
|
||||
byte* vera_layer_hscroll_l[2] = {VERA_L0_HSCROLL_L, VERA_L1_HSCROLL_L};
|
||||
byte* vera_layer_hscroll_h[2] = {VERA_L0_HSCROLL_H, VERA_L1_HSCROLL_H};
|
||||
|
||||
byte vera_layer_textcolor[2] = {WHITE, WHITE};
|
||||
byte vera_layer_backcolor[2] = {BLUE, BLUE};
|
||||
|
||||
// --- VERA addressing ---
|
||||
|
||||
@ -61,25 +35,12 @@ void vera_vram_address1(dword bankaddr, byte incr) {
|
||||
*VERA_ADDRX_H = <(*word_h) | incr;
|
||||
}
|
||||
|
||||
// Get the map base address of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Specifies the map base address of the layer, which is returned as a dword.
|
||||
// Note that the register only specifies bits 16:9 of the 17 total bit-address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes!
|
||||
dword vera_get_layer_mapbase_address(byte layer) {
|
||||
layer &= $1;
|
||||
byte mapbase = *vera_layer_mapbase[layer];
|
||||
dword address = mapbase;
|
||||
address <<= 8;
|
||||
address <<= 1;
|
||||
return address;
|
||||
}
|
||||
// --- VERA layer management ---
|
||||
|
||||
// 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_set_layer_config(char layer, char config) {
|
||||
void vera_layer_set_config(char layer, char config) {
|
||||
layer &= $1;
|
||||
char* addr = vera_layer_config[layer];
|
||||
*addr = config;
|
||||
@ -88,51 +49,50 @@ void vera_set_layer_config(char layer, char 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_get_layer_config(char layer) {
|
||||
layer &= $1;
|
||||
char vera_layer_get_config(char layer) {
|
||||
char* 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_set_layer_map_width_32(unsigned byte layer) {
|
||||
inline void vera_layer_set_width_32(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_WIDTH_MASK;
|
||||
*addr |= VERA_LAYER_WIDTH_32;
|
||||
}
|
||||
inline void vera_set_layer_map_width_64(unsigned byte layer) {
|
||||
inline void vera_layer_set_width_64(unsigned 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_set_layer_map_width_128(unsigned byte layer) {
|
||||
inline void vera_layer_set_width_128(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_WIDTH_MASK;
|
||||
*addr |= VERA_LAYER_WIDTH_128;
|
||||
}
|
||||
inline void vera_set_layer_map_width_256(unsigned byte layer) {
|
||||
inline void vera_layer_set_width_256(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_WIDTH_MASK;
|
||||
*addr |= VERA_LAYER_WIDTH_256;
|
||||
}
|
||||
inline void vera_set_layer_map_height_32(unsigned byte layer) {
|
||||
inline void vera_layer_set_height_32(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_HEIGHT_MASK;
|
||||
*addr |= VERA_LAYER_HEIGHT_32;
|
||||
}
|
||||
inline void vera_set_layer_map_height_64(unsigned byte layer) {
|
||||
inline void vera_layer_set_height_64(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_HEIGHT_MASK;
|
||||
*addr |= VERA_LAYER_HEIGHT_64;
|
||||
}
|
||||
inline void vera_set_layer_map_height_128(unsigned byte layer) {
|
||||
inline void vera_layer_set_height_128(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_HEIGHT_MASK;
|
||||
*addr |= VERA_LAYER_HEIGHT_128;
|
||||
}
|
||||
inline void vera_set_layer_map_height_256(unsigned byte layer) {
|
||||
inline void vera_layer_set_height_256(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_HEIGHT_MASK;
|
||||
*addr |= VERA_LAYER_HEIGHT_256;
|
||||
@ -140,13 +100,13 @@ inline void vera_set_layer_map_height_256(unsigned byte layer) {
|
||||
|
||||
// Get the map width or height of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
word vera_get_layer_map_width(unsigned byte layer) {
|
||||
word vera_layer_get_width(unsigned byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
byte mask = (byte)VERA_LAYER_WIDTH_MASK;
|
||||
return VERA_LAYER_WIDTH[ (*config & mask) >> 4];
|
||||
}
|
||||
|
||||
word vera_get_layer_map_height(unsigned byte layer) {
|
||||
word vera_layer_get_height(unsigned byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
byte mask = VERA_LAYER_HEIGHT_MASK;
|
||||
return VERA_LAYER_HEIGHT[ (*config & mask) >> 6];
|
||||
@ -154,22 +114,22 @@ word vera_get_layer_map_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_set_layer_color_depth_1BPP(unsigned byte layer) {
|
||||
inline void vera_layer_set_color_depth_1BPP(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_1BPP;
|
||||
}
|
||||
inline void vera_set_layer_color_depth_2BPP(unsigned byte layer) {
|
||||
inline void vera_layer_set_color_depth_2BPP(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_2BPP;
|
||||
}
|
||||
inline void vera_set_layer_color_depth_4BPP(unsigned byte layer) {
|
||||
inline void vera_layer_set_color_depth_4BPP(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_4BPP;
|
||||
}
|
||||
inline void vera_set_layer_color_depth_8BPP(unsigned byte layer) {
|
||||
inline void vera_layer_set_color_depth_8BPP(unsigned byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_8BPP;
|
||||
@ -178,7 +138,7 @@ inline void vera_set_layer_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_get_layer_color_depth(unsigned byte layer) {
|
||||
word vera_layer_get_color_depth(unsigned byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
byte mask = (byte)VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
return VERA_LAYER_COLOR_DEPTH[(*config & mask)];
|
||||
@ -186,22 +146,21 @@ word vera_get_layer_color_depth(unsigned byte layer) {
|
||||
|
||||
// Enable the layer to be displayed on the screen.
|
||||
// - layer: 0 or 1.
|
||||
inline void vera_show_layer(char layer) {
|
||||
inline void vera_layer_show(char layer) {
|
||||
*VERA_DC_VIDEO |= vera_layer_enable[layer];
|
||||
}
|
||||
|
||||
|
||||
// Disable the layer to be displayed on the screen.
|
||||
// - layer: 0 or 1.
|
||||
inline void vera_hide_layer(char layer) {
|
||||
inline void vera_layer_hide(char 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_is_layer_shown(char layer) {
|
||||
layer &= $1;
|
||||
char vera_layer_is_visible(char layer) {
|
||||
return *VERA_DC_VIDEO & vera_layer_enable[layer];
|
||||
}
|
||||
|
||||
@ -210,19 +169,61 @@ char vera_is_layer_shown(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_set_layer_mapbase(unsigned byte layer, unsigned byte mapbase) {
|
||||
layer &= $1;
|
||||
void vera_layer_set_mapbase(unsigned byte layer, unsigned byte mapbase) {
|
||||
unsigned byte* addr = vera_layer_mapbase[layer];
|
||||
*addr = mapbase;
|
||||
}
|
||||
|
||||
// Set the base of the map layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - dw_mapbase: a dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective mapbase vera register.
|
||||
// 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_address(byte layer, dword dw_mapbase) {
|
||||
|
||||
dw_mapbase = dw_mapbase & 0x1FF00; // Aligned to 2048 bit zones.
|
||||
byte bank_mapbase = (byte)>dw_mapbase;
|
||||
word offset_mapbase = <dw_mapbase;
|
||||
|
||||
vera_mapbase_address[layer] = dw_mapbase;
|
||||
vera_mapbase_offset[layer] = offset_mapbase;
|
||||
vera_mapbase_bank[layer] = bank_mapbase;
|
||||
|
||||
byte mapbase = >(<(dw_mapbase>>1));
|
||||
vera_layer_set_mapbase(layer,mapbase);
|
||||
}
|
||||
|
||||
// Get the map base address of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Specifies the map base address of the layer, which is returned as a dword.
|
||||
// Note that the register only specifies bits 16:9 of the 17 bit address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes!
|
||||
dword vera_layer_get_mapbase_address(byte layer) {
|
||||
return vera_mapbase_address[layer];
|
||||
}
|
||||
|
||||
// Get the map base bank of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Bank in vera vram.
|
||||
byte vera_layer_get_mapbase_bank(byte layer) {
|
||||
return vera_mapbase_bank[layer];
|
||||
}
|
||||
|
||||
// Get the map base lower 16-bit address (offset) of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Offset in vera vram of the specified bank.
|
||||
word vera_layer_get_mapbase_offset(byte layer) {
|
||||
return vera_mapbase_offset[layer];
|
||||
}
|
||||
|
||||
// Get the base of the map 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_get_layer_mapbase(unsigned byte layer) {
|
||||
layer &= $1;
|
||||
unsigned byte vera_layer_get_mapbase(unsigned byte layer) {
|
||||
unsigned byte* mapbase = vera_layer_mapbase[layer];
|
||||
return *mapbase;
|
||||
}
|
||||
@ -232,8 +233,7 @@ unsigned byte vera_get_layer_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_set_layer_tilebase(unsigned byte layer, unsigned byte tilebase) {
|
||||
layer &= $1;
|
||||
void vera_layer_set_tilebase(unsigned byte layer, unsigned byte tilebase) {
|
||||
unsigned byte* addr = vera_layer_tilebase[layer];
|
||||
*addr = tilebase;
|
||||
}
|
||||
@ -243,19 +243,44 @@ void vera_set_layer_tilebase(unsigned byte layer, unsigned byte tilebase) {
|
||||
// - 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_get_layer_tilebase(unsigned byte layer) {
|
||||
layer &= $1;
|
||||
unsigned byte* tilebase = vera_layer_tilebase[layer];
|
||||
byte vera_layer_get_tilebase(byte layer) {
|
||||
byte* tilebase = vera_layer_tilebase[layer];
|
||||
return *tilebase;
|
||||
}
|
||||
|
||||
// Set the base address of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - dw_tilebase: a dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective tilebase vera register.
|
||||
// Note that the resulting vera register holds 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_address(byte layer, dword dw_tilebase) {
|
||||
|
||||
dw_tilebase = dw_tilebase & 0x1FC00; // Aligned to 2048 bit zones.
|
||||
byte bank_tilebase = (byte)>dw_tilebase;
|
||||
word word_tilebase = <dw_tilebase;
|
||||
|
||||
vera_tilebase_address[layer] = dw_tilebase;
|
||||
vera_tilebase_offset[layer] = word_tilebase;
|
||||
vera_tilebase_bank[layer] = bank_tilebase;
|
||||
|
||||
byte* vera_tilebase = vera_layer_tilebase[layer];
|
||||
byte tilebase = >(<(dw_tilebase>>1));
|
||||
tilebase &= VERA_LAYER_TILEBASE_MASK; // Ensure that only tilebase is blanked, but keep the rest!
|
||||
//printf("tilebase = %x\n",tilebase);
|
||||
//while(!kbhit());
|
||||
tilebase = tilebase | ( *vera_tilebase & ~VERA_LAYER_TILEBASE_MASK );
|
||||
|
||||
vera_layer_set_tilebase(layer,tilebase);
|
||||
}
|
||||
|
||||
// Get the tile base address of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Specifies the base address of the tile map, which is calculated as an unsigned long int.
|
||||
// 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!
|
||||
dword vera_get_layer_tilebase_address(byte layer) {
|
||||
layer &= $1;
|
||||
dword vera_layer_get_tilebase_address(byte layer) {
|
||||
byte tilebase = *vera_layer_tilebase[layer];
|
||||
dword address = tilebase;
|
||||
address &= $FC;
|
||||
@ -271,8 +296,7 @@ dword vera_get_layer_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_set_layer_textcolor(unsigned byte layer, unsigned byte color) {
|
||||
layer &= $1;
|
||||
unsigned byte vera_layer_set_textcolor(unsigned byte layer, unsigned byte color) {
|
||||
unsigned byte old = vera_layer_textcolor[layer];
|
||||
vera_layer_textcolor[layer] = color;
|
||||
return old;
|
||||
@ -283,7 +307,7 @@ unsigned byte vera_set_layer_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_get_layer_textcolor(unsigned byte layer) {
|
||||
unsigned byte vera_layer_get_textcolor(unsigned byte layer) {
|
||||
layer &= $1;
|
||||
return vera_layer_textcolor[layer];
|
||||
}
|
||||
@ -293,7 +317,7 @@ unsigned byte vera_get_layer_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_set_layer_backcolor(unsigned byte layer, unsigned byte color) {
|
||||
unsigned byte vera_layer_set_backcolor(unsigned byte layer, unsigned byte color) {
|
||||
layer &= $1;
|
||||
unsigned byte old = vera_layer_backcolor[layer];
|
||||
vera_layer_backcolor[layer] = color;
|
||||
@ -305,7 +329,7 @@ unsigned byte vera_set_layer_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_get_layer_backcolor(unsigned byte layer) {
|
||||
unsigned byte vera_layer_get_backcolor(unsigned byte layer) {
|
||||
layer &= $1;
|
||||
return vera_layer_backcolor[layer];
|
||||
}
|
||||
@ -315,7 +339,7 @@ unsigned byte vera_get_layer_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_get_layer_color(unsigned byte layer) {
|
||||
unsigned byte vera_layer_get_color(unsigned byte layer) {
|
||||
layer &= $1;
|
||||
return ((vera_layer_backcolor[layer] << 4) | vera_layer_textcolor[layer]);
|
||||
}
|
||||
@ -324,7 +348,7 @@ 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) {
|
||||
inline void vera_layer_set_horizontal_scroll(byte layer, word scroll) {
|
||||
*vera_layer_hscroll_l[layer] = <scroll;
|
||||
*vera_layer_hscroll_h[layer] = >scroll;
|
||||
}
|
||||
@ -332,13 +356,27 @@ 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) {
|
||||
inline void vera_layer_set_vertical_scroll(byte layer, word scroll) {
|
||||
*vera_layer_vscroll_l[layer] = <scroll;
|
||||
*vera_layer_vscroll_h[layer] = >scroll;
|
||||
}
|
||||
|
||||
// Get the bit shift value required to skip a whole line fast.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Rowshift value to calculate fast from a y value to line offset in tile mode.
|
||||
byte vera_layer_get_rowshift(byte layer) {
|
||||
return vera_layer_rowshift[layer];
|
||||
}
|
||||
|
||||
void vera_mode_tile(byte layer, dword mapbase_dw, dword tilebase_dw, word mapwidth, word mapheight, byte tilewidth, byte tileheight, byte color_depth ) {
|
||||
// Get the value required to skip a whole line fast.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Skip value to calculate fast from a y value to line offset in tile mode.
|
||||
word vera_layer_get_rowskip(byte layer) {
|
||||
return vera_layer_rowskip[layer];
|
||||
}
|
||||
|
||||
|
||||
void vera_layer_mode_tile(byte layer, dword mapbase_address, dword dw_tilebase, word mapwidth, word mapheight, byte tilewidth, byte tileheight, byte color_depth ) {
|
||||
// config
|
||||
byte config = 0x00;
|
||||
switch(color_depth) {
|
||||
@ -359,19 +397,23 @@ void vera_mode_tile(byte layer, dword mapbase_dw, dword tilebase_dw, word mapwid
|
||||
switch(mapwidth) {
|
||||
case 32:
|
||||
config |= VERA_LAYER_WIDTH_32;
|
||||
vera_row_shift[layer] = 6;
|
||||
vera_layer_rowshift[layer] = 6;
|
||||
vera_layer_rowskip[layer] = 64;
|
||||
break;
|
||||
case 64:
|
||||
config |= VERA_LAYER_WIDTH_64;
|
||||
vera_row_shift[layer] = 7;
|
||||
vera_layer_rowshift[layer] = 7;
|
||||
vera_layer_rowskip[layer] = 128;
|
||||
break;
|
||||
case 128:
|
||||
config |= VERA_LAYER_WIDTH_128;
|
||||
vera_row_shift[layer] = 8;
|
||||
vera_layer_rowshift[layer] = 8;
|
||||
vera_layer_rowskip[layer] = 256;
|
||||
break;
|
||||
case 256:
|
||||
config |= VERA_LAYER_WIDTH_256;
|
||||
vera_row_shift[layer] = 9;
|
||||
vera_layer_rowshift[layer] = 9;
|
||||
vera_layer_rowskip[layer] = 512;
|
||||
break;
|
||||
}
|
||||
switch(mapheight) {
|
||||
@ -388,32 +430,32 @@ void vera_mode_tile(byte layer, dword mapbase_dw, dword tilebase_dw, word mapwid
|
||||
config |= VERA_LAYER_HEIGHT_256;
|
||||
break;
|
||||
}
|
||||
vera_set_layer_config(layer, config);
|
||||
vera_layer_set_config(layer, config);
|
||||
|
||||
// mapbase
|
||||
vera_mapbase_word[layer] = <mapbase_dw;
|
||||
vera_mapbase_bank[layer] = (byte)>mapbase_dw;
|
||||
vera_mapbase_dword[layer] = mapbase_dw;
|
||||
vera_mapbase_offset[layer] = <mapbase_address;
|
||||
vera_mapbase_bank[layer] = (byte)(>mapbase_address);
|
||||
vera_mapbase_address[layer] = mapbase_address;
|
||||
|
||||
mapbase_dw = mapbase_dw >> 1;
|
||||
byte mapbase = (byte)<(mapbase_dw >> 8);
|
||||
vera_set_layer_mapbase(layer,mapbase);
|
||||
mapbase_address = mapbase_address >> 1;
|
||||
byte mapbase = (byte)<(mapbase_address >> 8);
|
||||
vera_layer_set_mapbase(layer,mapbase);
|
||||
|
||||
|
||||
//printf("%lx\n",mapbase_dw);
|
||||
//printf("%lx\n",dw_mapbase);
|
||||
|
||||
// tilebase
|
||||
vera_tilebase_word[layer] = <tilebase_dw;
|
||||
vera_tilebase_bank[layer] = (byte)>tilebase_dw;
|
||||
vera_tilebase_dword[layer] = tilebase_dw;
|
||||
vera_tilebase_offset[layer] = <dw_tilebase;
|
||||
vera_tilebase_bank[layer] = (byte)>dw_tilebase;
|
||||
vera_tilebase_address[layer] = dw_tilebase;
|
||||
|
||||
//printf("tilebase word = %x\n",vera_tilebase_word[layer]);
|
||||
//printf("tilebase word = %x\n",vera_tilebase_offset[layer]);
|
||||
//printf("tilebase bank = %x\n",vera_tilebase_bank[layer]);
|
||||
//printf("tilebase dword = %lx\n",vera_tilebase_dword[layer]);
|
||||
//printf("tilebase dword = %lx\n",vera_tilebase_address[layer]);
|
||||
|
||||
tilebase_dw = tilebase_dw >> 1;
|
||||
byte tilebase = (byte)<(tilebase_dw >> 8);
|
||||
tilebase &= VERA_TILEBASE_MASK;
|
||||
dw_tilebase = dw_tilebase >> 1;
|
||||
byte tilebase = (byte)<(dw_tilebase >> 8);
|
||||
tilebase &= VERA_LAYER_TILEBASE_MASK;
|
||||
switch(tilewidth) {
|
||||
case 8:
|
||||
tilebase |= VERA_TILEBASE_WIDTH_8;
|
||||
@ -431,15 +473,15 @@ void vera_mode_tile(byte layer, dword mapbase_dw, dword tilebase_dw, word mapwid
|
||||
break;
|
||||
}
|
||||
//printf("tilebase = %x\n",tilebase);
|
||||
vera_set_layer_tilebase(layer,tilebase);
|
||||
vera_layer_set_tilebase(layer,tilebase);
|
||||
}
|
||||
|
||||
// --- TILE FUNCTIONS ---
|
||||
|
||||
void vera_tile_area(byte layer, word tileindex, byte x, byte y, byte w, byte h, byte hflip, byte vflip, byte offset) {
|
||||
|
||||
dword mapbase = vera_mapbase_dword[layer];
|
||||
byte shift = vera_row_shift[layer];
|
||||
dword mapbase = vera_mapbase_address[layer];
|
||||
byte shift = vera_layer_rowshift[layer];
|
||||
word rowskip = (word)1 << shift;
|
||||
hflip = vera_layer_hflip[hflip];
|
||||
vflip = vera_layer_vflip[vflip];
|
||||
|
@ -20,12 +20,12 @@ void main() {
|
||||
clrscr();
|
||||
|
||||
// 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(1);
|
||||
// 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);
|
||||
|
||||
@ -42,14 +42,14 @@ void main() {
|
||||
*VERA_IEN = VERA_VSYNC;
|
||||
CLI();
|
||||
|
||||
vera_show_layer(0);
|
||||
vera_layer_show(0);
|
||||
while(!kbhit());
|
||||
|
||||
vera_hide_layer(0);
|
||||
vera_layer_hide(0);
|
||||
textcolor(GREY);
|
||||
bgcolor(GREEN);
|
||||
draw_characters(tilebase);
|
||||
vera_show_layer(0);
|
||||
vera_layer_show(0);
|
||||
|
||||
screenlayer(1);
|
||||
|
||||
@ -70,11 +70,11 @@ void main() {
|
||||
while(!kbhit());
|
||||
|
||||
screenlayer(0);
|
||||
vera_hide_layer(0);
|
||||
vera_layer_hide(0);
|
||||
textcolor(DARK_GREY);
|
||||
bgcolor(BLACK);
|
||||
draw_characters(tilebase);
|
||||
vera_show_layer(0);
|
||||
vera_layer_show(0);
|
||||
|
||||
screenlayer(1);
|
||||
gotoxy(0,20);
|
||||
@ -142,8 +142,8 @@ __interrupt(rom_sys_cx16) void irq_vsync() {
|
||||
scroll_y = 0;
|
||||
}
|
||||
|
||||
vera_set_layer_horizontal_scroll(0,(word)scroll_x);
|
||||
vera_set_layer_vertical_scroll(0,(word)scroll_y);
|
||||
vera_layer_set_horizontal_scroll(0,(word)scroll_x);
|
||||
vera_layer_set_vertical_scroll(0,(word)scroll_y);
|
||||
|
||||
// Reset the VSYNC interrupt
|
||||
*VERA_ISR = VERA_VSYNC;
|
||||
|
94
src/test/kc/examples/cx16/tilemap_2bpp_16_x_16.c
Normal file
94
src/test/kc/examples/cx16/tilemap_2bpp_16_x_16.c
Normal file
@ -0,0 +1,94 @@
|
||||
// Example program for the Commander X16.
|
||||
// Demonstrates the usage of the VERA tile map modes and layering.
|
||||
|
||||
// Author: Sven Van de Velde
|
||||
|
||||
// The default layer of the CX16 is layer 1, but the tiles are written on layer 0.
|
||||
// The CX16 starts in tile map mode, 2BPP in 4 color mode, and uses 16x16 tiles.
|
||||
|
||||
// An explanation is given how this mode is organized, and how the tiles display and coloring works.
|
||||
// Pälette offsets are explained also.
|
||||
|
||||
#include <conio.h>
|
||||
#include <printf.h>
|
||||
|
||||
void main() {
|
||||
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
clrscr();
|
||||
|
||||
//vera_layer_mode_tile(1, 0x10000, 0x00000, 128, 64, 8, 8, 1);
|
||||
vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 16, 16, 2);
|
||||
//vera_layer_mode_tile(0, 0x04000, 0x14000, 128, 128, 16, 16, 2);
|
||||
|
||||
byte tiles[256] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
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,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
|
||||
memcpy_to_vram(1, 0x4000, tiles, 256);
|
||||
|
||||
//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, 40, 30, 0, 0, 0);
|
||||
|
||||
// Draw 4 squares with each tile, starting from row 4, width 1, height 1, separated by 2 characters.
|
||||
vera_tile_area(0, 0, 4, 2, 1, 1, 0, 0, 0);
|
||||
vera_tile_area(0, 1, 10, 2, 1, 1, 0, 0, 0);
|
||||
vera_tile_area(0, 2, 16, 2, 1, 1, 0, 0, 0);
|
||||
vera_tile_area(0, 3, 22, 2, 1, 1, 0, 0, 0);
|
||||
|
||||
// Draw 4 squares with each tile, starting from row 6, width 4, height 4, separated by 2 characters.
|
||||
vera_tile_area(0, 0, 4, 4, 4, 4, 0, 0, 0);
|
||||
vera_tile_area(0, 1, 10, 4, 4, 4, 0, 0, 0);
|
||||
vera_tile_area(0, 2, 16, 4, 4, 4, 0, 0, 0);
|
||||
vera_tile_area(0, 3, 22, 4, 4, 4, 0, 0, 0);
|
||||
|
||||
word tile = 0;
|
||||
byte offset = 0;
|
||||
|
||||
byte row = 10;
|
||||
|
||||
for(byte r:0..3) {
|
||||
byte column = 4;
|
||||
for(byte c:0..16) {
|
||||
vera_tile_area(0, tile, column, row, 1, 1, 0, 0, offset);
|
||||
column+=2;
|
||||
offset++;
|
||||
}
|
||||
tile++;
|
||||
tile &= 0x3;
|
||||
row += 2;
|
||||
}
|
||||
|
||||
vera_layer_show(0);
|
||||
|
||||
gotoxy(0,40);
|
||||
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");
|
||||
printf("each tile can have a variation of 4 colors.\n");
|
||||
printf("the vera palette of 256 colors, can be used by setting the palette\n");
|
||||
printf("offset for each tile.\n");
|
||||
printf("here each column is displaying the same tile, but with different offsets!\n");
|
||||
printf("each offset aligns to multiples of 16 colors, and only the first 4 colors\n");
|
||||
printf("can be used per offset!\n");
|
||||
printf("however, the first color will always be transparent (black).\n");
|
||||
|
||||
while(!kbhit());
|
||||
}
|
@ -56,7 +56,7 @@ void main() {
|
||||
row += 4;
|
||||
}
|
||||
|
||||
vera_show_layer(0);
|
||||
vera_layer_show(0);
|
||||
|
||||
gotoxy(0,40);
|
||||
printf("vera in tile mode 8 x 8, color depth 2 bits per pixel.\n");
|
||||
|
222
src/test/kc/examples/cx16/tilemap_4bpp_16_x_16.c
Normal file
222
src/test/kc/examples/cx16/tilemap_4bpp_16_x_16.c
Normal file
@ -0,0 +1,222 @@
|
||||
// Example program for the Commander X16.
|
||||
// Demonstrates the usage of the VERA tile map modes and layering.
|
||||
|
||||
// Author: Sven Van de Velde
|
||||
|
||||
// The default layer of the CX16 is layer 1, but the tiles are written on layer 0.
|
||||
// The CX16 starts in tile map mode, 2BPP in 4 color mode, and uses 16x16 tiles.
|
||||
|
||||
// An explanation is given how this mode is organized, and how the tiles display and coloring works.
|
||||
// Pälette offsets are explained also.
|
||||
|
||||
#include <veralib.h>
|
||||
#include <printf.h>
|
||||
|
||||
void main() {
|
||||
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
clrscr();
|
||||
|
||||
vera_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,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
|
||||
memcpy_to_vram(1, 0x4000, tiles, 2048);
|
||||
|
||||
//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, 40, 30, 0, 0, 0);
|
||||
|
||||
word tile = 0;
|
||||
|
||||
// Draw 4 squares with each tile, starting from row 4, width 1, height 1, separated by 2 characters.
|
||||
tile = 0;
|
||||
byte column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 1, 1, 1, 0, 0, 0);
|
||||
column+=4;
|
||||
tile++;
|
||||
}
|
||||
column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 3, 1, 1, 0, 0, 0);
|
||||
column+=4;
|
||||
tile++;
|
||||
}
|
||||
|
||||
tile = 0;
|
||||
column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 5, 3, 3, 0, 0, 0);
|
||||
column+=4;
|
||||
tile++;
|
||||
}
|
||||
column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 9, 3, 3, 0, 0, 0);
|
||||
column+=4;
|
||||
tile++;
|
||||
}
|
||||
|
||||
tile = 0;
|
||||
byte offset = 0;
|
||||
|
||||
byte row = 13;
|
||||
|
||||
for(byte r:0..7) {
|
||||
byte column = 1;
|
||||
for(byte c:0..31) {
|
||||
vera_tile_area(0, tile, column, row, 1, 1, 0, 0, offset);
|
||||
column+=1;
|
||||
tile++;
|
||||
if((c & 0x0f) == 0x0f) offset++;
|
||||
tile &= 0x0f;
|
||||
}
|
||||
row += 1;
|
||||
}
|
||||
|
||||
vera_layer_show(0);
|
||||
|
||||
gotoxy(0,46);
|
||||
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");
|
||||
printf("each tile can have a variation of 16 colors.\n");
|
||||
printf("the vera palette of 256 colors, can be used by setting the palette\n");
|
||||
printf("offset for each tile.\n");
|
||||
printf("here each column is displaying the same tile, but with different offsets!\n");
|
||||
printf("each offset aligns to multiples of 16 colors in the palette!.\n");
|
||||
printf("however, the first color will always be transparent (black).\n");
|
||||
|
||||
while(!kbhit());
|
||||
}
|
125
src/test/kc/examples/cx16/tilemap_4bpp_8_x_8.c
Normal file
125
src/test/kc/examples/cx16/tilemap_4bpp_8_x_8.c
Normal file
@ -0,0 +1,125 @@
|
||||
// Example program for the Commander X16.
|
||||
// Demonstrates the usage of the VERA tile map modes and layering.
|
||||
|
||||
// Author: Sven Van de Velde
|
||||
|
||||
// The default layer of the CX16 is layer 1, but the tiles are written on layer 0.
|
||||
|
||||
// An explanation is given how this mode is organized, and how the tiles display and coloring works.
|
||||
// Pälette offsets are explained also.
|
||||
|
||||
#include <veralib.h>
|
||||
#include <printf.h>
|
||||
|
||||
void main() {
|
||||
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
clrscr();
|
||||
|
||||
vera_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,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
// Draw 4 squares with each tile, starting from row 4, width 1, height 1, separated by 2 characters.
|
||||
tile = 0;
|
||||
byte column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 1, 1, 1, 0, 0, 0);
|
||||
column+=8;
|
||||
tile++;
|
||||
}
|
||||
column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 3, 1, 1, 0, 0, 0);
|
||||
column+=8;
|
||||
tile++;
|
||||
}
|
||||
|
||||
tile = 0;
|
||||
column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 5, 6, 6, 0, 0, 0);
|
||||
column+=8;
|
||||
tile++;
|
||||
}
|
||||
column = 1;
|
||||
for(byte c:0..7) {
|
||||
vera_tile_area(0, tile, column, 12, 6, 6, 0, 0, 0);
|
||||
column+=8;
|
||||
tile++;
|
||||
}
|
||||
|
||||
tile = 0;
|
||||
byte offset = 0;
|
||||
|
||||
byte row = 20;
|
||||
|
||||
for(byte r:0..7) {
|
||||
byte column = 1;
|
||||
for(byte c:0..31) {
|
||||
vera_tile_area(0, tile, column, row, 2, 2, 0, 0, offset);
|
||||
column+=2;
|
||||
tile++;
|
||||
if((c & 0x0f) == 0x0f) offset++;
|
||||
tile &= 0x0f;
|
||||
}
|
||||
row += 2;
|
||||
}
|
||||
|
||||
vera_layer_show(0);
|
||||
|
||||
gotoxy(0,46);
|
||||
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");
|
||||
printf("each tile can have a variation of 16 colors.\n");
|
||||
printf("the vera palette of 256 colors, can be used by setting the palette\n");
|
||||
printf("offset for each tile.\n");
|
||||
printf("here each column is displaying the same tile, but with different offsets!\n");
|
||||
printf("each offset aligns to multiples of 16 colors in the palette!.\n");
|
||||
printf("however, the first color will always be transparent (black).\n");
|
||||
|
||||
while(!kbhit());
|
||||
}
|
152
src/test/kc/examples/cx16/tilemap_8bpp_16_x_16.c
Normal file
152
src/test/kc/examples/cx16/tilemap_8bpp_16_x_16.c
Normal file
@ -0,0 +1,152 @@
|
||||
// Example program for the Commander X16.
|
||||
// Demonstrates the usage of the VERA tile map modes and layering.
|
||||
|
||||
// Author: Sven Van de Velde
|
||||
|
||||
// The default layer of the CX16 is layer 1, but the tiles are written on layer 0.
|
||||
|
||||
// An explanation is given how this mode is organized, and how the tiles display and coloring works.
|
||||
// Pälette offsets are explained also.
|
||||
|
||||
#include <conio.h>
|
||||
#include <printf.h>
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
byte tiles[256] = {
|
||||
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
};
|
||||
|
||||
// Before we can load the tiles into memory we need to re-arrange a few things!
|
||||
// The amount of tiles is 256, the color depth is 256, so each tile is 256 bytes!
|
||||
// That is 65356 bytes of memory, which is 64K. Yup! One memory bank in VRAM.
|
||||
// VERA VRAM holds in bank 1 many registers that interfere loading all of this data.
|
||||
// So it is better to load all in bank 0, but then there is an other issue.
|
||||
// So the default CX16 character set is located in bank 0, at address 0xF800.
|
||||
// So we need to move this character set to bank 1, suggested is at address 0xF000.
|
||||
// The CX16 by default writes textual output to layer 1 in text mode, so we need to
|
||||
// realign the moved character set to 0xf000 as the new tile base for layer 1.
|
||||
// We also will need to realign for layer 1 the map base from 0x00000 to 0x10000.
|
||||
// This is now all easily done with a few statements in the new kickc vera lib ...
|
||||
|
||||
// Copy block of memory (from VRAM to VRAM)
|
||||
// Copies the values from the location pointed by src to the location pointed by dest.
|
||||
// The method uses the VERA access ports 0 and 1 to copy data from and to in VRAM.
|
||||
// - src_bank: 64K VRAM bank number to copy from (0/1).
|
||||
// - src: pointer to the location to copy from. Note that the address is a 16 bit value!
|
||||
// - src_increment: the increment indicator, VERA needs this because addressing increment is automated by VERA at each access.
|
||||
// - dest_bank: 64K VRAM bank number to copy to (0/1).
|
||||
// - dest: pointer to the location to copy to. Note that the address is a 16 bit value!
|
||||
// - dest_increment: the increment indicator, VERA needs this because addressing increment is automated by VERA at each access.
|
||||
// - num: The number of bytes to copy
|
||||
// void memcpy_in_vram(char dest_bank, void *dest, char dest_increment, char src_bank, void *src, char src_increment, unsigned int num );
|
||||
memcpy_in_vram(1, 0xF000, VERA_INC_1, 0, 0xF800, VERA_INC_0, 256*8); // We copy the 128 character set of 8 bytes each.
|
||||
|
||||
// Set the base of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - dw_tilebase: a dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective tilebase vera register.
|
||||
// Note that the resulting vera register holds 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!
|
||||
vera_layer_set_tilebase_address(1, 0x1F000); // Here we set layer 1 new character set base (tile base) to the new address.
|
||||
|
||||
// Set the base of the map layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - dw_mapbase: a dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective mapbase vera register.
|
||||
// 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_address(byte layer, dword dw_mapbase);
|
||||
vera_layer_set_mapbase_address(1, 0x10000); // Here we set the map base of layer 1 to 0x10000;
|
||||
|
||||
vera_layer_mode_tile(1, 0x10000, 0x00000, 128, 64, 8, 8, 1);
|
||||
|
||||
screenlayer(1);
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
clrscr();
|
||||
|
||||
while(!kbhit());
|
||||
|
||||
// Now we can use the full bank 0!
|
||||
// We set the mapbase of the tile demo to output to 0x12000,
|
||||
// and the tilebase is set to 0x0000!
|
||||
vera_layer_mode_tile(0, 0x10000, 0x00000, 64, 64, 16, 16, 8);
|
||||
|
||||
|
||||
word tilebase = 0x0000;
|
||||
memcpy_to_vram(0, tilebase, tiles, 256);
|
||||
tilebase+=256;
|
||||
for(byte t:1..10) {
|
||||
for(byte p:0..255) {
|
||||
tiles[p]+=1;
|
||||
}
|
||||
memcpy_to_vram(1, tilebase, tiles, 256);
|
||||
tilebase+=256;
|
||||
}
|
||||
|
||||
//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, 40, 30, 0, 0, 0);
|
||||
|
||||
word tile = 0;
|
||||
|
||||
// Draw 4 squares with each tile, starting from row 4, width 1, height 1, separated by 2 characters.
|
||||
byte row = 1;
|
||||
for(byte r:0..15) {
|
||||
byte column = 1;
|
||||
for(byte c:0..15) {
|
||||
vera_tile_area(0, tile, column, row, 1, 1, 0, 0, 0);
|
||||
column+=2;
|
||||
tile++;
|
||||
tile &= 0xff;
|
||||
}
|
||||
row += 2;
|
||||
}
|
||||
|
||||
tile = 0;
|
||||
row = 20;
|
||||
for(byte r:0..7) {
|
||||
byte column = 1;
|
||||
for(byte c:0..31) {
|
||||
vera_tile_area(0, tile, column, row, 2, 2, 0, 0, 0);
|
||||
column+=2;
|
||||
tile++;
|
||||
tile &= 0xff;
|
||||
}
|
||||
row += 2;
|
||||
}
|
||||
|
||||
vera_layer_show(0);
|
||||
|
||||
gotoxy(0,46);
|
||||
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");
|
||||
printf("each tile can have a variation of 256 colors.\n");
|
||||
printf("the vera palette of 256 colors, can be used by setting the palette\n");
|
||||
printf("offset for each tile.\n");
|
||||
printf("here each column is displaying the same tile, but with different offsets!\n");
|
||||
printf("each offset aligns to multiples of 16 colors in the palette!.\n");
|
||||
printf("however, the first color will always be transparent (black).\n");
|
||||
|
||||
while(!kbhit());
|
||||
}
|
90
src/test/kc/examples/cx16/tilemap_8bpp_8_x_8.c
Normal file
90
src/test/kc/examples/cx16/tilemap_8bpp_8_x_8.c
Normal file
@ -0,0 +1,90 @@
|
||||
// Example program for the Commander X16.
|
||||
// Demonstrates the usage of the VERA tile map modes and layering.
|
||||
|
||||
// Author: Sven Van de Velde
|
||||
|
||||
// The default layer of the CX16 is layer 1, but the tiles are written on layer 0.
|
||||
|
||||
// An explanation is given how this mode is organized, and how the tiles display and coloring works.
|
||||
// Pälette offsets are explained also.
|
||||
|
||||
#include <veralib.h>
|
||||
#include <printf.h>
|
||||
|
||||
void main() {
|
||||
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
clrscr();
|
||||
|
||||
vera_mode_tile(0, 0x04000, 0x14000, 128, 128, 8, 8, 8);
|
||||
|
||||
byte tiles[64] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
|
||||
word tilebase = 0x4000;
|
||||
memcpy_to_vram(1, tilebase, tiles, 64);
|
||||
tilebase+=64;
|
||||
for(byte t:1..255) {
|
||||
for(byte p:0..63) {
|
||||
tiles[p]+=1;
|
||||
}
|
||||
memcpy_to_vram(1, tilebase, tiles, 64);
|
||||
tilebase+=64;
|
||||
}
|
||||
|
||||
//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;
|
||||
|
||||
// Draw 4 squares with each tile, starting from row 4, width 1, height 1, separated by 2 characters.
|
||||
byte row = 1;
|
||||
for(byte r:0..7) {
|
||||
byte column = 1;
|
||||
for(byte c:0..31) {
|
||||
vera_tile_area(0, tile, column, row, 1, 1, 0, 0, 0);
|
||||
column+=2;
|
||||
tile++;
|
||||
tile &= 0xff;
|
||||
}
|
||||
row += 2;
|
||||
}
|
||||
|
||||
tile = 0;
|
||||
row = 20;
|
||||
for(byte r:0..7) {
|
||||
byte column = 1;
|
||||
for(byte c:0..31) {
|
||||
vera_tile_area(0, tile, column, row, 2, 2, 0, 0, 0);
|
||||
column+=2;
|
||||
tile++;
|
||||
tile &= 0xff;
|
||||
}
|
||||
row += 2;
|
||||
}
|
||||
|
||||
vera_layer_show(0);
|
||||
|
||||
gotoxy(0,46);
|
||||
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");
|
||||
printf("each tile can have a variation of 256 colors.\n");
|
||||
printf("the vera palette of 256 colors, can be used by setting the palette\n");
|
||||
printf("offset for each tile.\n");
|
||||
printf("here each column is displaying the same tile, but with different offsets!\n");
|
||||
printf("each offset aligns to multiples of 16 colors in the palette!.\n");
|
||||
printf("however, the first color will always be transparent (black).\n");
|
||||
|
||||
while(!kbhit());
|
||||
}
|
@ -39,12 +39,12 @@ void main() {
|
||||
// It displays the characters in 1BPP 16x16 color mode!
|
||||
unsigned byte dcvideo = *VERA_DC_VIDEO;
|
||||
printf("\nvera dc video = %x\n", dcvideo);
|
||||
unsigned byte config = vera_get_layer_config(1);
|
||||
unsigned byte config = vera_layer_get_config(1);
|
||||
printf("\nvera layer 1 config = %x\n", config);
|
||||
unsigned byte layershown = vera_is_layer_shown(1);
|
||||
unsigned byte layershown = vera_layer_is_visible(1);
|
||||
printf("vera layer 1 shown = %c\n", layershown);
|
||||
unsigned byte mapbase = vera_get_layer_mapbase(1);
|
||||
unsigned byte tilebase = vera_get_layer_tilebase(1);
|
||||
unsigned byte mapbase = vera_layer_get_mapbase(1);
|
||||
unsigned byte tilebase = vera_layer_get_tilebase(1);
|
||||
printf("vera layer 1 mapbase = %hhx, tilebase = %hhx\n", mapbase, tilebase);
|
||||
|
||||
// Wait for a keypress and after clear the line!
|
||||
@ -62,17 +62,17 @@ void main() {
|
||||
// But first, we also print the layer 0 VERA configuration.
|
||||
// This statement sets the base of the display layer 1 at VRAM address 0x0200
|
||||
|
||||
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_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));
|
||||
|
||||
textcolor(WHITE);
|
||||
config = vera_get_layer_config(0);
|
||||
printf("\nvera layer 0 config = %x\n", vera_get_layer_config(0));
|
||||
layershown = vera_is_layer_shown(0);
|
||||
config = vera_layer_get_config(0);
|
||||
printf("\nvera layer 0 config = %x\n", vera_layer_get_config(0));
|
||||
layershown = vera_layer_is_visible(0);
|
||||
printf("vera layer 0 shown = %x\n", layershown);
|
||||
mapbase = vera_get_layer_mapbase(0);
|
||||
tilebase = vera_get_layer_tilebase(0);
|
||||
mapbase = vera_layer_get_mapbase(0);
|
||||
tilebase = vera_layer_get_tilebase(0);
|
||||
printf("vera layer 0 mapbase = %x, tilebase = %x\n", mapbase, tilebase);
|
||||
|
||||
// Now we print the layer 0 text on the layer 0!
|
||||
@ -98,10 +98,10 @@ void main() {
|
||||
clearline();
|
||||
|
||||
// Now we activate layer 0.
|
||||
vera_show_layer(0);
|
||||
vera_layer_show(0);
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
printf("vera layer 0 shown = %x. ", vera_is_layer_shown(0));
|
||||
printf("vera layer 0 shown = %x. ", vera_layer_is_visible(0));
|
||||
|
||||
// Wait for a keypress and after clear the line!
|
||||
textcolor(YELLOW);
|
||||
@ -110,10 +110,10 @@ void main() {
|
||||
while(!kbhit());
|
||||
clearline();
|
||||
|
||||
vera_hide_layer(0);
|
||||
vera_layer_hide(0);
|
||||
textcolor(WHITE);
|
||||
bgcolor(BLACK);
|
||||
printf("vera layer 0 shown = %x. ", vera_is_layer_shown(0));
|
||||
printf("vera layer 0 shown = %x. ", vera_layer_is_visible(0));
|
||||
|
||||
// Wait for a keypress and after clear the line!
|
||||
textcolor(YELLOW);
|
||||
|
Loading…
Reference in New Issue
Block a user