refactor screen2_init_bitmap

This commit is contained in:
nino-porcino 2021-12-15 10:54:58 +01:00
parent 19a741cfa2
commit c7d3cc2e6c
4 changed files with 35 additions and 34 deletions

View File

@ -156,8 +156,7 @@ byte amiga_data[612] = {
void demo_amiga_hand() {
TMS_INIT(SCREEN2_TABLE);
SCREEN2_FILL();
screen2_square_sprites();
screen2_init_bitmap(COLOR_BYTE(COLOR_WHITE,COLOR_BLACK));
SCREEN2_PUTS(0, 0, COLOR_BYTE(COLOR_BLACK,COLOR_WHITE), "*** P-LAB VIDEO CARD SYSTEM ***");
SCREEN2_PUTS(0, 2, COLOR_BYTE(COLOR_BLACK,COLOR_WHITE), "16K VRAM BYTES FREE");

View File

@ -40,9 +40,6 @@ void drawLogo() {
// introduction screen
void introScreen() {
TMS_INIT(SCREEN2_TABLE);
SCREEN2_FILL();
screen2_square_sprites();
set_color(COLOR_BLACK);
// simulate cls (TODO improve speed)

View File

@ -395,6 +395,10 @@ void main() {
memcpy(LOWRAM_START, DATAINCODE, LOWRAM_SIZE);
#endif
// initialize the screen
TMS_INIT(SCREEN2_TABLE);
screen2_init_bitmap(COLOR_BYTE(COLOR_BLACK,COLOR_BLACK));
while(1) {
introScreen();
initGame();

View File

@ -19,23 +19,42 @@ const word SCREEN2_SPRITE_PATTERNS = 0x1800;
const word SCREEN2_SPRITE_ATTRS = 0x3b00;
const word SCREEN2_SIZE = (32*24);
void SCREEN2_FILL() {
// fills name table x3 with increasing numbers
set_vram_write_addr(SCREEN2_NAME_TABLE);
for(word i=0;i<SCREEN2_SIZE;i++) {
TMS_WRITE_DATA_PORT(i & 0xFF);
// prepare the screen 2 to be used as a bitmap
void screen2_init_bitmap(byte color) {
// erase the first sprite pattern
set_vram_write_addr(SCREEN2_SPRITE_PATTERNS); // start writing in the sprite patterns
for(byte i=0;i<8;i++) {
TMS_WRITE_DATA_PORT(0); NOP;
}
// fill pattern table with 0 (clear screen)
set_vram_write_addr(SCREEN2_PATTERN_TABLE);
for(word i=768*8;i!=0;i--) {
TMS_WRITE_DATA_PORT(0);
// set all sprite coordinates to 0
set_vram_write_addr(SCREEN2_SPRITE_ATTRS); // start writing in the sprite attribute
for(byte i=0;i<32;i++) {
TMS_WRITE_DATA_PORT(0); NOP; // y coordinate
TMS_WRITE_DATA_PORT(0); NOP; // x coordinate
TMS_WRITE_DATA_PORT(0); NOP; // name
TMS_WRITE_DATA_PORT(i); NOP; // color
}
// fill color table with black on white
set_vram_write_addr(SCREEN2_COLOR_TABLE);
for(word i=768*8;i!=0;i--) {
TMS_WRITE_DATA_PORT(COLOR_BYTE(COLOR_BLACK,COLOR_WHITE));
TMS_WRITE_DATA_PORT(color);
NOP;
}
// fills name table x3 with increasing numbers
set_vram_write_addr(SCREEN2_NAME_TABLE);
for(word i=0;i<SCREEN2_SIZE;i++) {
TMS_WRITE_DATA_PORT(i & 0xFF);
NOP;
}
// fill pattern table with 0 (clear screen)
set_vram_write_addr(SCREEN2_PATTERN_TABLE);
for(word i=768*8;i!=0;i--) {
TMS_WRITE_DATA_PORT(0);
NOP;
}
}
@ -80,27 +99,9 @@ void SCREEN2_PLOT(byte x, byte y) {
TMS_WRITE_DATA_PORT(data);
}
void screen2_square_sprites() {
// fills first sprite pattern with 255
set_vram_write_addr(SCREEN2_SPRITE_PATTERNS); // start writing in the sprite patterns
for(byte i=0;i<8;i++) {
TMS_WRITE_DATA_PORT(0);
}
// set sprite coordinates
set_vram_write_addr(SCREEN2_SPRITE_ATTRS); // start writing in the sprite attribute
for(byte i=0;i<32;i++) {
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // y coordinate
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // x coordinate
TMS_WRITE_DATA_PORT(0); NOP; NOP; NOP; NOP; // name
TMS_WRITE_DATA_PORT(i); NOP; NOP; NOP; NOP; // color
}
}
void prova_screen2() {
TMS_INIT(SCREEN2_TABLE);
SCREEN2_FILL();
screen2_square_sprites();
screen2_init_bitmap(COLOR_BYTE(COLOR_WHITE,COLOR_BLACK));
SCREEN2_PUTS(0,0,COLOR_BYTE(COLOR_BLACK,COLOR_WHITE),"*** P-LAB VIDEO CARD SYSTEM ***");
SCREEN2_PUTS(0,2,COLOR_BYTE(COLOR_BLACK,COLOR_WHITE),"16K VRAM BYTES FREE");