kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
have proper text but shifted to the right
rodzic
5494503e51
commit
68c26ba800
|
@ -115,12 +115,16 @@ void cpc_Init(void)
|
|||
{
|
||||
for(int i = 0; i < PALETTE_SIZE; i++)
|
||||
{
|
||||
emu_SetPaletteEntry(firmware_palette[hardware_colours[i]].R, firmware_palette[hardware_colours[i]].G, firmware_palette[hardware_colours[i]].B, hardware_colours[i]);
|
||||
emu_SetPaletteEntry(firmware_palette[hardware_colours[i]].R,
|
||||
firmware_palette[hardware_colours[i]].G,
|
||||
firmware_palette[hardware_colours[i]].B,
|
||||
hardware_colours[i]);
|
||||
}
|
||||
if (bitstream == 0) bitstream = (unsigned char *)emu_Malloc(WIDTH*HEIGHT);
|
||||
|
||||
pins = z80_init(&CPU);
|
||||
memset(RAM, 0, sizeof(RAM));
|
||||
vsync_wait = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,9 +132,7 @@ void cpc_Init(void)
|
|||
*/
|
||||
void cpc_Start(char* filename)
|
||||
{
|
||||
ga_config.lower_rom_enable = true;
|
||||
ga_config.upper_rom_enable = false;
|
||||
ga_config.interrupt_counter = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,7 +188,7 @@ void cpc_Step(void)
|
|||
{
|
||||
// printf("Waiting in the next cycle.\n");
|
||||
pins = pins | Z80_WAIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// printf("Not waiting in the next cycle.\n");
|
||||
|
|
|
@ -5,23 +5,24 @@
|
|||
#include "crtc.h"
|
||||
|
||||
uint8_t registers[16] = {
|
||||
63, // horizontal_total
|
||||
40, // horitzontal_displayed
|
||||
46, // horizontal_sync_position
|
||||
142, // horizontal_and_vertical_sync_widths -> VVVVHHHH, so bits 0-3 correspond to hsync width, 4-7 to vsync.
|
||||
38, // vertical_total
|
||||
0, // horizontal_total
|
||||
0, // horitzontal_displayed
|
||||
0, // horizontal_sync_position
|
||||
0, // horizontal_and_vertical_sync_widths -> VVVVHHHH, so bits 0-3 correspond to hsync width, 4-7 to vsync.
|
||||
0, // vertical_total
|
||||
0, // vertical_total_adjust
|
||||
25, // vertical_displayed
|
||||
30, // vertical_sync_position
|
||||
0, // vertical_displayed
|
||||
0, // vertical_sync_position
|
||||
0, // interlace_and_skew
|
||||
7, // max_raster_address
|
||||
0, // max_raster_address
|
||||
0, // cursor_start_raster
|
||||
0, // cursor_end_raster
|
||||
48, // display_start_addr_high
|
||||
0, // display_start_addr_high
|
||||
0, // display_start_addr_low
|
||||
0, // cursor_addr_high
|
||||
0 // cursor_addr_low
|
||||
};
|
||||
|
||||
uint8_t selected_register = 0;
|
||||
uint8_t horizontal_count = 0;
|
||||
uint8_t char_line_count = 0;
|
||||
|
@ -51,7 +52,6 @@ void crtc_step()
|
|||
|
||||
scanline_count = 0;
|
||||
char_line_count++;
|
||||
|
||||
}
|
||||
|
||||
if(char_line_count > registers[4])
|
||||
|
@ -86,7 +86,7 @@ uint16_t crtc_generate_addr()
|
|||
|
||||
bool is_within_display()
|
||||
{
|
||||
return horizontal_count < registers[2] && scanline_count < registers[6];
|
||||
return horizontal_count < registers[1] && scanline_count < registers[6];
|
||||
}
|
||||
|
||||
bool is_hsync_active()
|
||||
|
|
|
@ -13,13 +13,14 @@ extern uint8_t horizontal_count;
|
|||
extern uint8_t char_line_count;
|
||||
extern uint8_t scanline_count;
|
||||
extern uint8_t vertical_adjust_count;
|
||||
extern uint8_t microsec_count_crtc;
|
||||
|
||||
bool is_hsync_active();
|
||||
bool is_vsync_active();
|
||||
bool is_within_display();
|
||||
uint16_t crtc_generate_addr();
|
||||
void crtc_step();
|
||||
void write_crt_controller(unsigned short address, uint8_t value);
|
||||
uint8_t read_crt_controller(unsigned short address);
|
||||
extern bool is_hsync_active();
|
||||
extern bool is_vsync_active();
|
||||
extern bool is_within_display();
|
||||
extern uint16_t crtc_generate_addr();
|
||||
extern void crtc_step();
|
||||
extern void write_crt_controller(unsigned short address, uint8_t value);
|
||||
extern uint8_t read_crt_controller(unsigned short address);
|
||||
|
||||
#endif
|
|
@ -8,7 +8,7 @@
|
|||
#include "cpc.h"
|
||||
|
||||
struct GAConfig ga_config;
|
||||
bool vsync_wait = true;
|
||||
bool vsync_wait;
|
||||
uint8_t microsecond_count_ga = 0;
|
||||
|
||||
/**
|
||||
|
@ -130,7 +130,13 @@ void address_to_pixels()
|
|||
vsync_wait = false;
|
||||
}
|
||||
|
||||
if(ga_config.hsync_active || ga_config.vsync_active)
|
||||
// if(ga_config.hsync_active || ga_config.vsync_active)
|
||||
// {
|
||||
// // need to output border/black somehow. how to do that considering the 320x200 buffer?
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(!is_within_display())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -141,70 +147,60 @@ void address_to_pixels()
|
|||
uint8_t encodedByte = RAM[address];
|
||||
uint8_t pixel0, pixel1, pixel2, pixel3;
|
||||
uint8_t* pixels = (uint8_t*) calloc(4, 8*sizeof(uint8_t));
|
||||
if(address >= 0xC000)
|
||||
switch(ga_config.screen_mode)
|
||||
{
|
||||
//printf("address from CRTC: %x \nRAM data: %x \n", address, RAM[address]);
|
||||
switch(ga_config.screen_mode)
|
||||
{
|
||||
case 0:
|
||||
pixel0 = (encodedByte & 0x80) >> 7 |
|
||||
(encodedByte & 0x08) >> 2 |
|
||||
(encodedByte & 0x20) >> 3 |
|
||||
(encodedByte & 0x02) << 2;
|
||||
pixel1 = (encodedByte & 0x40) >> 6 |
|
||||
(encodedByte & 0x04) >> 1 |
|
||||
(encodedByte & 0x10) >> 2 |
|
||||
(encodedByte & 0x01) << 3;
|
||||
pixels[0] = pixel0;
|
||||
pixels[1] = pixel1;
|
||||
case 0:
|
||||
pixel0 = (encodedByte & 0x80) >> 7 |
|
||||
(encodedByte & 0x08) >> 2 |
|
||||
(encodedByte & 0x20) >> 3 |
|
||||
(encodedByte & 0x02) << 2;
|
||||
pixel1 = (encodedByte & 0x40) >> 6 |
|
||||
(encodedByte & 0x04) >> 1 |
|
||||
(encodedByte & 0x10) >> 2 |
|
||||
(encodedByte & 0x01) << 3;
|
||||
pixels[0] = pixel0;
|
||||
pixels[1] = pixel1;
|
||||
|
||||
for(int pixelIdx = 0; pixelIdx < 2; pixelIdx++)
|
||||
{
|
||||
for(int color = 0; color < 4; color++)
|
||||
{
|
||||
write_to_bitstream(ga_rgb_to_vga(firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].R,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].G,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].B));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
pixel0 = (encodedByte & 0x80) >> 7 |
|
||||
(encodedByte & 0x08) >> 2;
|
||||
pixel1 = (encodedByte & 0x40) >> 6 |
|
||||
(encodedByte & 0x04) >> 1;
|
||||
pixel2 = (encodedByte & 0x02) |
|
||||
(encodedByte & 0x20) >> 5;
|
||||
pixel3 = (encodedByte & 0x10) >> 4 |
|
||||
(encodedByte & 0x01) << 1;
|
||||
pixels[0] = pixel0;
|
||||
pixels[1] = pixel1;
|
||||
pixels[2] = pixel2;
|
||||
pixels[3] = pixel3;
|
||||
for(int pixelIdx = 0; pixelIdx < 2; pixelIdx++)
|
||||
{
|
||||
write_to_bitstream(ga_rgb_to_vga(firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].R,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].G,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].B));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
pixel0 = (encodedByte & 0x80) >> 7 |
|
||||
(encodedByte & 0x08) >> 2;
|
||||
pixel1 = (encodedByte & 0x40) >> 6 |
|
||||
(encodedByte & 0x04) >> 1;
|
||||
pixel2 = (encodedByte & 0x02) |
|
||||
(encodedByte & 0x20) >> 5;
|
||||
pixel3 = (encodedByte & 0x10) >> 4 |
|
||||
(encodedByte & 0x01) << 1;
|
||||
pixels[0] = pixel0;
|
||||
pixels[1] = pixel1;
|
||||
pixels[2] = pixel2;
|
||||
pixels[3] = pixel3;
|
||||
|
||||
for(int pixelIdx = 0; pixelIdx < 4; pixelIdx++)
|
||||
{
|
||||
for(int color = 0; color < 2; color++)
|
||||
{
|
||||
write_to_bitstream(ga_rgb_to_vga(firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].R,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].G,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].B));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
uint8_t pixel;
|
||||
for (int color = 0; color < 8; color++)
|
||||
{
|
||||
pixel = (encodedByte >> 7 - color) & 1;
|
||||
write_to_bitstream(ga_rgb_to_vga(firmware_palette[hardware_colours[ga_config.pen_colours[pixel]]].R,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixel]]].G,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixel]]].B));
|
||||
}
|
||||
break;
|
||||
}
|
||||
free(pixels);
|
||||
}
|
||||
for(int pixelIdx = 0; pixelIdx < 4; pixelIdx++)
|
||||
{
|
||||
write_to_bitstream(ga_rgb_to_vga(firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].R,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].G,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixels[pixelIdx]]]].B));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
uint8_t pixel;
|
||||
for (int color = 0; color < 8; color++)
|
||||
{
|
||||
pixel = (encodedByte >> 7 - color) & 1;
|
||||
write_to_bitstream(ga_rgb_to_vga(firmware_palette[hardware_colours[ga_config.pen_colours[pixel]]].R,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixel]]].G,
|
||||
firmware_palette[hardware_colours[ga_config.pen_colours[pixel]]].B));
|
||||
}
|
||||
break;
|
||||
}
|
||||
free(pixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue