kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
ga convert address to pixel data
rodzic
9de9455ef9
commit
1657336884
|
@ -1,8 +1,8 @@
|
|||
#include "cpc.h"
|
||||
|
||||
#include "pico.h"
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
#include "cpc.h"
|
||||
|
||||
extern "C" {
|
||||
#include "emuapi.h"
|
||||
#include "platform_config.h"
|
||||
|
@ -16,8 +16,8 @@ extern "C" {
|
|||
* Declarations of instances of the RAM, VRAM, processor and other required components.
|
||||
*/
|
||||
|
||||
static byte RAM[0x10000]; // 64k
|
||||
static byte bitstream[0x4000]; // 16k video ram to be used by PIO.
|
||||
uint8_t RAM[0x10000]; // 64k
|
||||
uint8_t bitstream[0x4000]; // 16k video ram to be used by PIO.
|
||||
static Z80 CPU;
|
||||
extern struct GAConfig gateArray;
|
||||
|
||||
|
@ -32,7 +32,7 @@ void cpc_Init(void)
|
|||
|
||||
void cpc_Step(void)
|
||||
{
|
||||
|
||||
// probably where i will call crtc_step() and ga_step()
|
||||
}
|
||||
|
||||
void cpc_Start(char* filename)
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
#ifndef CPC_H_
|
||||
#define CPC_H_
|
||||
|
||||
#ifndef PICO_H_
|
||||
#include "pico.h"
|
||||
#include "pico/stdlib.h"
|
||||
#endif
|
||||
|
||||
extern uint8_t RAM[0x10000];
|
||||
extern uint8_t bitstream[0x4000];
|
||||
|
||||
extern void cpc_Init(void);
|
||||
extern void cpc_Step(void);
|
||||
extern void cpc_Start(char* filename);
|
||||
|
|
|
@ -22,9 +22,9 @@ uint8_t registers[16] = {
|
|||
0 // cursor_addr_low
|
||||
};
|
||||
uint8_t selectedRegister = 0;
|
||||
uint8_t horizontalCount = 0; // C0
|
||||
uint8_t characterLineCount = 0; // C4
|
||||
uint8_t scanlineCount = 0; // C9
|
||||
uint8_t horizontalCount = 0;
|
||||
uint8_t characterLineCount = 0;
|
||||
uint8_t scanlineCount = 0;
|
||||
uint8_t verticalAdjustCount = 0;
|
||||
uint16_t memoryAddr = 0;
|
||||
|
||||
|
@ -59,7 +59,7 @@ void crtc_step()
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t generateAddress()
|
||||
uint16_t crtc_generateAddress()
|
||||
{
|
||||
// Video address is created as follows:
|
||||
// Bit 0: Always 0
|
||||
|
|
|
@ -7,7 +7,13 @@
|
|||
#endif
|
||||
|
||||
extern uint16_t memoryAddr;
|
||||
uint16_t generateAddress();
|
||||
extern uint8_t selectedRegister;
|
||||
extern uint8_t horizontalCount;
|
||||
extern uint8_t characterLineCount;
|
||||
extern uint8_t scanlineCount;
|
||||
extern uint8_t verticalAdjustCount;
|
||||
|
||||
uint16_t crtc_generateAddress();
|
||||
void crtc_step();
|
||||
void writeCRTC(unsigned short address, uint8_t value);
|
||||
uint8_t readCRTC(unsigned short address);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "ga.h"
|
||||
#include "crtc.h"
|
||||
#include "cpc.h"
|
||||
|
||||
struct GAConfig gaConfig;
|
||||
/**
|
||||
|
@ -45,11 +46,56 @@ struct RGB palette[32] = {
|
|||
{50, 50, 100} // Pastel Blue
|
||||
};
|
||||
|
||||
// TODO: Add a step() function, or something, that reads from the crtc's hsync and vsync and generates the actual
|
||||
// pixel data based on its config data.
|
||||
void ga_step()
|
||||
{
|
||||
return;
|
||||
// TODO add responses to hsync and vsync signals.
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
uint16_t address = crtc_generateAddress() + i;
|
||||
uint8_t encodedByte = RAM[address];
|
||||
switch(gaConfig.screenMode)
|
||||
{
|
||||
case 0:
|
||||
uint8_t pixel0 = (encodedByte & 0x80) >> 7 |
|
||||
(encodedByte & 0x08) >> 2 |
|
||||
(encodedByte & 0x20) >> 3 |
|
||||
(encodedByte & 0x02) << 2;
|
||||
|
||||
uint8_t pixel1 = (encodedByte & 0x40) >> 6 |
|
||||
(encodedByte & 0x04) >> 1 |
|
||||
(encodedByte & 0x10) >> 2 |
|
||||
(encodedByte & 0x01) << 3;
|
||||
|
||||
// TODO may not be correct, needs testing.
|
||||
|
||||
bitstream[0xC000 - address] = pixel0;
|
||||
bitstream[0xC000 - address + 1] = pixel1;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
uint8_t pixel0 = (encodedByte & 0x80) >> 7 |
|
||||
(encodedByte & 0x08) >> 2;
|
||||
uint8_t pixel1 = (encodedByte & 0x40) >> 6 |
|
||||
(encodedByte & 0x04) >> 1;
|
||||
uint8_t pixel2 = (encodedByte & 0x02) |
|
||||
(encodedByte & 0x20) >> 5;
|
||||
uint8_t pixel3 = (encodedByte & 0x10) >> 4 |
|
||||
(encodedByte & 0x01) << 1;
|
||||
|
||||
bitstream[0xC000 - address] = pixel0;
|
||||
bitstream[0xC000 - address + 1] = pixel1;
|
||||
bitstream[0xC000 - address + 2] = pixel2;
|
||||
bitstream[0xC000 - address + 3] = pixel3;
|
||||
break;
|
||||
case 2:
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
bitstream[0xC000 - address + j] = (encodedByte >> 7 - j) & 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void select_pen(uint8_t value)
|
||||
|
@ -81,7 +127,7 @@ void do_rom_bank_screen_cfg(uint8_t value)
|
|||
{
|
||||
case 0b00:
|
||||
// mode 0
|
||||
// ga_config.screen_mode = 0;
|
||||
gaConfig.screenMode = 0;
|
||||
break;
|
||||
case 0b01:
|
||||
// mode 1
|
||||
|
@ -89,7 +135,7 @@ void do_rom_bank_screen_cfg(uint8_t value)
|
|||
break;
|
||||
case 0b10:
|
||||
// mode 2
|
||||
// ga_config.screen_mode = 2;
|
||||
gaConfig.screenMode = 2;
|
||||
break;
|
||||
case 0b11:
|
||||
// mode 3, unused.
|
||||
|
|
Ładowanie…
Reference in New Issue