add sprites.h, rename files

This commit is contained in:
nino-porcino 2021-12-17 09:26:42 +01:00
parent d9065f8f44
commit 94fd376754
4 changed files with 23 additions and 14 deletions

View File

@ -51,6 +51,9 @@ void screen1_prepare() {
// fill name table with spaces (32)
screen1_cls();
// clear all the sprites
tms_clear_sprites();
// fill pattern table with 0
tms_set_vram_write_addr(TMS_PATTERN_TABLE);
for(word i=256*8;i!=0;i--) {

View File

@ -4,20 +4,8 @@ const word SCREEN2_SIZE = (32*24);
// prepare the screen 2 to be used as a bitmap
void screen2_init_bitmap(byte color) {
// erase the first sprite pattern
tms_set_vram_write_addr(TMS_SPRITE_PATTERNS); // start writing in the sprite patterns
for(byte i=0;i<8;i++) {
TMS_WRITE_DATA_PORT(0); NOP;
}
// set all sprite coordinates to 0
tms_set_vram_write_addr(TMS_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
}
// erases all the sprites
tms_clear_sprites();
// fill pattern table with 0 (clear screen)
tms_set_vram_write_addr(TMS_PATTERN_TABLE);

17
lib/sprites.h Normal file
View File

@ -0,0 +1,17 @@
// clears all the sprites
void tms_clear_sprites() {
// fills first sprite pattern with 0
tms_set_vram_write_addr(TMS_SPRITE_PATTERNS);
for(byte i=0;i<8;i++) {
TMS_WRITE_DATA_PORT(0);
}
// set sprite coordinates to (0,0) and set pattern name 0
tms_set_vram_write_addr(TMS_SPRITE_ATTRS);
for(byte i=0;i<32;i++) {
TMS_WRITE_DATA_PORT((6+i)*8); NOP; NOP; NOP; NOP; // y coordinate
TMS_WRITE_DATA_PORT((6+i)*8); 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
}
}

View File

@ -159,6 +159,7 @@ void tms_set_external_video(byte val) {
#include "apple1.h"
#include "font8x8.h"
#include "sprites.h"
#include "tms_screen1.h"
#include "tms_screen2.h"
#include "interrupt.h"