mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-09 05:25:01 +00:00
Takes a stab at tile reversal and vertical scrolling.
This commit is contained in:
@@ -437,18 +437,19 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
|||||||
if(pixel_target_) {
|
if(pixel_target_) {
|
||||||
const int pixels_left = pixels_end - output_column_;
|
const int pixels_left = pixels_end - output_column_;
|
||||||
const int pixel_location = output_column_ - first_pixel_column_;
|
const int pixel_location = output_column_ - first_pixel_column_;
|
||||||
|
const int reverses[2] = {0, 7};
|
||||||
for(int c = 0; c < pixels_left; ++c) {
|
for(int c = 0; c < pixels_left; ++c) {
|
||||||
const int column = (pixel_location + c) >> 3;
|
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 =
|
int value =
|
||||||
((
|
((
|
||||||
((master_system_.tile_graphics[column][0] << shift) & 0x800) |
|
((master_system_.tile_graphics[column][0] << shift) & 0x800) |
|
||||||
((master_system_.tile_graphics[column][1] << (shift - 1)) & 0x400) |
|
((master_system_.tile_graphics[column][1] << (shift - 1)) & 0x400) |
|
||||||
((master_system_.tile_graphics[column][2] << (shift - 2)) & 0x200) |
|
((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;
|
) >> 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;
|
pixel_target_ += pixels_left;
|
||||||
}
|
}
|
||||||
@@ -766,6 +767,18 @@ void TMS9918::set_register(int address, uint8_t value) {
|
|||||||
text_colour_ = low_write_ >> 4;
|
text_colour_ = low_write_ >> 4;
|
||||||
background_colour_ = low_write_ & 0xf;
|
background_colour_ = low_write_ & 0xf;
|
||||||
break;
|
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 {
|
} else {
|
||||||
// This is a write to the RAM pointer.
|
// This is a write to the RAM pointer.
|
||||||
|
@@ -126,6 +126,9 @@ class Base {
|
|||||||
} names[32];
|
} names[32];
|
||||||
uint8_t tile_graphics[32][4];
|
uint8_t tile_graphics[32][4];
|
||||||
size_t next_column = 0;
|
size_t next_column = 0;
|
||||||
|
|
||||||
|
uint8_t horizontal_scroll = 0;
|
||||||
|
uint8_t vertical_scroll = 0;
|
||||||
} master_system_;
|
} master_system_;
|
||||||
|
|
||||||
enum class ScreenMode {
|
enum class ScreenMode {
|
||||||
@@ -218,7 +221,7 @@ class Base {
|
|||||||
#define fetch_tile_name(column) {\
|
#define fetch_tile_name(column) {\
|
||||||
size_t address = pattern_address_base + ((column) << 1); \
|
size_t address = pattern_address_base + ((column) << 1); \
|
||||||
master_system_.names[column].flags = ram_[address+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) {\
|
#define fetch_tile(column) {\
|
||||||
@@ -265,8 +268,10 @@ class Base {
|
|||||||
- column n+3, tile graphic first word
|
- column n+3, tile graphic first word
|
||||||
- column n+3, tile graphic second 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) {
|
switch(start) {
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user