1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-09 06:29:33 +00:00

Adds enough to the Apple II's video that I can see what's going on with soft switches.

This commit is contained in:
Thomas Harte 2018-04-15 21:55:26 -04:00
parent 465c38f03c
commit 6a79ce9eb1

View File

@ -35,14 +35,16 @@ template <class BusHandler> class Video {
crt_->set_composite_sampling_function( crt_->set_composite_sampling_function(
"float composite_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate, float phase, float amplitude)" "float composite_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate, float phase, float amplitude)"
"{" "{"
// "uint texValue = texture(sampler, coordinate).r;"
// "texValue <<= int(icoordinate.x * 8) & 7;"
// "return float(texValue & 128u);"
"uint texValue = texture(sampler, coordinate).r;" "uint texValue = texture(sampler, coordinate).r;"
"texValue <<= int(icoordinate.x * 8) & 7;" "texValue <<= uint(icoordinate.x * 7.0) % 7u;"
"return float(texValue & 128u);" "return float(texValue & 64u);"
// "uint texValue = texture(sampler, coordinate).r;"
// "texValue <<= uint(icoordinate.x * 7.0) % 7u;"
// "return float(texValue & 128u);"
"}"); "}");
// TODO: the above has precision issues. Fix!
// Show only the centre 75% of the TV frame. // Show only the centre 75% of the TV frame.
crt_->set_video_signal(Outputs::CRT::VideoSignal::Composite); crt_->set_video_signal(Outputs::CRT::VideoSignal::Composite);
crt_->set_visible_area(Outputs::CRT::Rect(0.115f, 0.117f, 0.77f, 0.77f)); crt_->set_visible_area(Outputs::CRT::Rect(0.115f, 0.117f, 0.77f, 0.77f));
@ -92,10 +94,12 @@ template <class BusHandler> class Video {
const uint16_t line_address = static_cast<uint16_t>(0x400 + (character_row >> 3) * 40 + ((character_row&7) << 7)); const uint16_t line_address = static_cast<uint16_t>(0x400 + (character_row >> 3) * 40 + ((character_row&7) << 7));
for(int c = column_; c < pixel_end; ++c) { for(int c = column_; c < pixel_end; ++c) {
// TODO: proper address calculation.
const uint16_t address = static_cast<uint16_t>(line_address + c); const uint16_t address = static_cast<uint16_t>(line_address + c);
const uint8_t character = bus_handler_.perform_read(address); const uint8_t character = bus_handler_.perform_read(address);
pixel_pointer_[c] = character_rom_[(static_cast<int>(character) << 3) + pixel_row]; const int index = (character & 0x7f) << 3;
const std::size_t character_address = static_cast<std::size_t>(index + pixel_row);
pixel_pointer_[c] = character_rom_[character_address] ^ ((character & 0x80) ? 0x00 : 0xff);
} }
if(ending_column >= 40) { if(ending_column >= 40) {
@ -146,12 +150,29 @@ template <class BusHandler> class Video {
} }
// Inputs for the various soft switches. // Inputs for the various soft switches.
void set_graphics_mode() {} void set_graphics_mode() {
void set_text_mode() {} printf("Graphics mode\n");
void set_mixed_mode(bool) {} }
void set_video_page(int) {}
void set_low_resolution() {} void set_text_mode() {
void set_high_resolution() {} printf("Text mode\n");
}
void set_mixed_mode(bool mixed_mode) {
printf("Mixed mode: %s\n", mixed_mode ? "true" : "false");
}
void set_video_page(int page) {
printf("Video page: %d\n", page);
}
void set_low_resolution() {
printf("Low resolution\n");
}
void set_high_resolution() {
printf("High resolution\n");
}
void set_character_rom(const std::vector<uint8_t> &character_rom) { void set_character_rom(const std::vector<uint8_t> &character_rom) {
character_rom_ = character_rom; character_rom_ = character_rom;