1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-28 09:54:49 +00:00

Takes a stab at tile reversal and vertical scrolling.

This commit is contained in:
Thomas Harte 2018-09-28 22:37:10 -04:00
parent 7b9bb772ca
commit 0d8af010b6
2 changed files with 24 additions and 6 deletions

View File

@ -437,18 +437,19 @@ void TMS9918::run_for(const HalfCycles cycles) {
if(pixel_target_) {
const int pixels_left = pixels_end - output_column_;
const int pixel_location = output_column_ - first_pixel_column_;
const int reverses[2] = {0, 7};
for(int c = 0; c < pixels_left; ++c) {
const int column = (pixel_location + c) >> 3;
const int shift = 4 + ((pixel_location + c) & 7);
const int shift = 4 + (((pixel_location + c) & 7) ^ reverses[(master_system_.names[column].flags&2) >> 1]);
int value =
((
((master_system_.tile_graphics[column][0] << shift) & 0x800) |
((master_system_.tile_graphics[column][1] << (shift - 1)) & 0x400) |
((master_system_.tile_graphics[column][2] << (shift - 2)) & 0x200) |
(master_system_.tile_graphics[column][3] << (shift - 3))
((master_system_.tile_graphics[column][3] << (shift - 3)) & 0x100)
) >> 8) << 4;
pixel_target_[c] = (value << 24) | (value << 16) | (value << 8) | value;
pixel_target_[c] = static_cast<uint32_t>((value << 24) | (value << 16) | (value << 8) | value);
}
pixel_target_ += pixels_left;
}
@ -766,6 +767,18 @@ void TMS9918::set_register(int address, uint8_t value) {
text_colour_ = low_write_ >> 4;
background_colour_ = low_write_ & 0xf;
break;
case 8:
if(is_sega_vdp(personality_)) {
master_system_.horizontal_scroll = low_write_;
}
break;
case 9:
if(is_sega_vdp(personality_)) {
master_system_.vertical_scroll = low_write_;
}
break;
}
} else {
// This is a write to the RAM pointer.

View File

@ -126,6 +126,9 @@ class Base {
} names[32];
uint8_t tile_graphics[32][4];
size_t next_column = 0;
uint8_t horizontal_scroll = 0;
uint8_t vertical_scroll = 0;
} master_system_;
enum class ScreenMode {
@ -218,7 +221,7 @@ class Base {
#define fetch_tile_name(column) {\
size_t address = pattern_address_base + ((column) << 1); \
master_system_.names[column].flags = ram_[address+1]; \
master_system_.names[column].offset = static_cast<size_t>((((master_system_.names[column].flags&1) << 8) | ram_[address]) << 5) + sub_row; \
master_system_.names[column].offset = static_cast<size_t>((((master_system_.names[column].flags&1) << 8) | ram_[address]) << 5) + sub_row[(master_system_.names[column].flags&4) >> 2]; \
}
#define fetch_tile(column) {\
@ -265,8 +268,10 @@ class Base {
- column n+3, tile graphic first word
- column n+3, tile graphic second word
*/
const size_t pattern_address_base = (pattern_name_address_ | size_t(0x3ff)) & static_cast<size_t>(((row_ & ~7) << 3) | 0x3800);
const size_t sub_row = static_cast<size_t>((row_ & 7) << 2);
const int scrolled_row = (row_ + master_system_.vertical_scroll) % 224;
const size_t pattern_address_base = (pattern_name_address_ | size_t(0x3ff)) & static_cast<size_t>(((scrolled_row & ~7) << 3) | 0x3800);
const size_t sub_row[2] = {static_cast<size_t>((scrolled_row & 7) << 2), 28 ^ static_cast<size_t>((scrolled_row & 7) << 2)};
switch(start) {
default: