Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VFrown Improvements #18

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(wildcard src/backend/lib/*.c)\
$(wildcard src/core/*.c)\
$(wildcard src/core/hw/*.c)\

# platform
# Platform
ifndef platform
platform=linux
endif
Expand All @@ -34,7 +34,7 @@ else ifeq ($(platform), web)
endif


# build type
# Build type
ifndef build
build=debug
endif
Expand Down Expand Up @@ -65,3 +65,7 @@ VFrown: $(obj)

clean:
rm -f $(obj)

recompile:
make clean
make
18 changes: 9 additions & 9 deletions src/core/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Bus_Reset() {
void Bus_LoadROM(const char* filePath) {
FILE* file = fopen(filePath, "rb");
if (!file) {
VSmile_Error("unable to load ROM - can't open \"%s\"", filePath);
VSmile_Error("Unable to load ROM - can't open \"%s\"", filePath);
return;
}

Expand All @@ -69,7 +69,7 @@ void Bus_LoadROM(const char* filePath) {
fseek(file, 0, SEEK_SET);

if (this.romSize > BUS_SIZE*sizeof(uint16_t)) {
VSmile_Error("file too large!");
VSmile_Error("File is too large!");
this.romSize = BUS_SIZE*sizeof(uint16_t);
}
if (this.romBuffer)
Expand All @@ -85,7 +85,7 @@ void Bus_LoadROM(const char* filePath) {
void Bus_LoadSysRom(const char* filePath) {
FILE* file = fopen(filePath, "rb");
if (!file) {
VSmile_Warning("unable to load system rom - can't open \"%s\"", filePath);
VSmile_Warning("Unable to load system rom - can't open \"%s\"", filePath);
return;
}

Expand Down Expand Up @@ -121,7 +121,7 @@ uint16_t Bus_Load(uint32_t addr) {
return SPU_Read(addr);
}
else if (addr < 0x3d00) {
VSmile_Warning("read from internal memory location %04x", addr);
VSmile_Warning("Read from internal memory location %04x", addr);
return 0x0000;
}
else if (addr < IO_START+IO_SIZE+DMA_SIZE) {
Expand All @@ -143,10 +143,10 @@ uint16_t Bus_Load(uint32_t addr) {
return DMA_Read(addr);
}

VSmile_Warning("unknown read from IO port %04x at %06x\n", addr, CPU_GetCSPC());
VSmile_Warning("Unknown read from IO port %04x at %06x\n", addr, CPU_GetCSPC());
return 0x0000;
} else if (addr < 0x4000) {
VSmile_Warning("read from internal memory location %04x", addr);
VSmile_Warning("Read from internal memory location %04x", addr);
return 0x0000;
}

Expand Down Expand Up @@ -180,7 +180,7 @@ void Bus_Store(uint32_t addr, uint16_t data) {
return;
}
else if (addr < 0x3d00) {
VSmile_Warning("write to internal memory location %04x with %04x", addr, data);
VSmile_Warning("Write to internal memory location %04x with %04x", addr, data);
return;
}
else if (addr < IO_START+IO_SIZE+DMA_SIZE) {
Expand All @@ -207,11 +207,11 @@ void Bus_Store(uint32_t addr, uint16_t data) {
return;
}

VSmile_Warning("write to unknown IO port %04x with %04x at %06x", addr, data, CPU_GetCSPC());
VSmile_Warning("Write to unknown IO port %04x with %04x at %06x", addr, data, CPU_GetCSPC());
return;
}
else if (addr < 0x4000) {
VSmile_Warning("write to internal memory location %04x with %04x", addr, data);
VSmile_Warning("Write to internal memory location %04x with %04x", addr, data);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions src/core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void CPU_OpSPC() {
// Perform unsigned multiply on two operands and store result in r3 and r4
void CPU_OpMULU() {
if (this.ins.opN == 1 && this.ins.opA == 7)
VSmile_Error("invalid multiplication at 0x%06x (opN = %01x, opA = %01x)", CPU_GetCSPC(), this.ins.opN, this.ins.opA);
VSmile_Error("Invalid multiplication at 0x%06x (opN = %01x, opA = %01x)", CPU_GetCSPC(), this.ins.opN, this.ins.opA);

uint16_t a = this.r[this.ins.opA];
uint16_t b = this.r[this.ins.opB];
Expand All @@ -463,7 +463,7 @@ void CPU_OpMULU() {
// Perform signed multiply on two operands and store result in r3 and r4
void CPU_OpMULS() {
if (this.ins.opN == 1 && this.ins.opA == 7)
VSmile_Error("invalid multiplication at 0x%06x (opN = %01x, opA = %01x)", CPU_GetCSPC(), this.ins.opN, this.ins.opA);
VSmile_Error("Invalid multiplication at 0x%06x (opN = %01x, opA = %01x)", CPU_GetCSPC(), this.ins.opN, this.ins.opA);

uint16_t a = this.r[this.ins.opA];
int16_t b = this.r[this.ins.opB];
Expand All @@ -485,7 +485,7 @@ void CPU_OpMULS() {
// Push PC and SR to the stack and perform a long jump to a specified location
void CPU_OpCALL() {
if ((this.ins.opA & 1) != 0)
VSmile_Error("illegal opcode 0x%04x at 0x%06x", this.ins.raw, CPU_GetCSPC());
VSmile_Error("Illegal opcode 0x%04x at 0x%06x", this.ins.raw, CPU_GetCSPC());

uint16_t lowerPC = CPU_FetchNext();
CPU_Push(this.pc, 0);
Expand All @@ -499,7 +499,7 @@ void CPU_OpCALL() {
// Perform a long jump to a specified location
void CPU_OpJMPF() {
if (this.ins.opA != 7)
VSmile_Error("illegal opcode 0x%04x at 0x%06x", this.ins.raw, CPU_GetCSPC());
VSmile_Error("Illegal opcode 0x%04x at 0x%06x", this.ins.raw, CPU_GetCSPC());

CPU_SetCSPC((this.ins.imm << 16) | CPU_FetchNext());

Expand Down Expand Up @@ -552,7 +552,7 @@ void CPU_OpMISC() {
case 0x25: // NOP
break;

default: VSmile_Error("unimplemented special instruction at 0x%06x (op1 = 0x%01x, offset = 0x%02x)", CPU_GetCSPC(), this.ins.op1, this.ins.imm);
default: VSmile_Error("Unimplemented special instruction at 0x%06x (op1 = 0x%01x, offset = 0x%02x)", CPU_GetCSPC(), this.ins.op1, this.ins.imm);
}

this.cycles += 2;
Expand Down Expand Up @@ -750,7 +750,7 @@ void CPU_OpPSH() {


void CPU_OpBAD() {
VSmile_Error("unknown CPU instruction %04x at %06x", this.ins.raw, this.pc);
VSmile_Error("Unknown CPU instruction %04x at %06x", this.ins.raw, this.pc);
}


Expand All @@ -777,7 +777,7 @@ void CPU_AddrImm6() {

// Invalid addressing mode
void CPU_AddrUnknown() {
VSmile_Error("unimplemented operand mode at 0x%06x (op1 = 0x%01x)", CPU_GetCSPC(), this.ins.op1);
VSmile_Error("Unimplemented operand mode at 0x%06x (op1 = 0x%01x)", CPU_GetCSPC(), this.ins.op1);
}


Expand Down
8 changes: 4 additions & 4 deletions src/core/hw/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ uint8_t Controller_SendByte() {


void Controller_RecieveByte(uint8_t data) {
// printf("ctrl recieving %02x\n", data);
// printf("CTRL receiving %02x\n", data);
if (controllers[0].select) {
controllers[0].rxBuffer = data;
Timer_Reset(controllers[0].rxTimer);
Expand All @@ -116,7 +116,7 @@ void Controller_RecieveByte(uint8_t data) {
bool Controller_PushTx(uint8_t ctrlNum, uint8_t data) {
Controller_t* this = &controllers[ctrlNum];

// printf("controller push %02x\n", data);
// printf("Controller push %02x\n", data);

if (!this->txEmpty && (this->txHead == this->txTail)) {
VSmile_Warning("Tx byte %02x discarded because FIFO is full", data);
Expand All @@ -135,15 +135,15 @@ uint8_t Controller_PopTx(uint8_t ctrlNum) {
Controller_t* this = &controllers[ctrlNum];

if (this->txEmpty) {
VSmile_Warning("returning 0x00 because Tx FIFO is empty");
VSmile_Warning("Returning 0x00 because Tx FIFO is empty");
return 0x00;
}

uint8_t data = this->txFifo[this->txTail];
this->txTail = (this->txTail + 1) & 0xf;
this->txEmpty = (this->txHead == this->txTail);

// printf("controller pop %02x\n", data);
// printf("Controller pop %02x\n", data);

return data;
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/hw/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bool DMA_Init() {

void DMA_Cleanup() {

return true;
}


Expand Down Expand Up @@ -38,7 +39,7 @@ uint16_t DMA_Read(uint16_t addr) {
case 0x3e02: return this.size;
case 0x3e03: return this.dst;
default:
VSmile_Warning("unknown read from DMA address %04x at %06x", addr, CPU_GetCSPC());
VSmile_Warning("Unknown read from DMA address %04x at %06x", addr, CPU_GetCSPC());
}

return 0x0000;
Expand All @@ -61,6 +62,6 @@ void DMA_Write(uint16_t addr, uint16_t data) {
} return;

default:
VSmile_Warning("unknown read from DMA address %04x at %06x", addr, CPU_GetCSPC());
VSmile_Warning("Unknown read from DMA address %04x at %06x", addr, CPU_GetCSPC());
}
}
8 changes: 4 additions & 4 deletions src/core/hw/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ uint16_t GPIO_GetIOB(uint16_t mask) {

// Send data to IO port B
void GPIO_SetIOB(uint16_t data, uint16_t mask) {
// printf("write to IOB (data: %04x, mask: %04x)\n", data, mask);
// printf("Write to IOB (data: %04x, mask: %04x)\n", data, mask);
if (mask & 7) {
Bus_SetChipSelectMode((data & 7));
// printf("chip select set to %d\n", (data & 7));
// printf("Chip select set to %d\n", (data & 7));
}
}

Expand All @@ -151,15 +151,15 @@ uint16_t GPIO_GetIOC(uint16_t mask) {
uint16_t data = this.region;
data |= Controller_GetRequests();

// printf("read from IOC (%04x) at %06x\n", data, CPU_GetCSPC());
// printf("Read from IOC (%04x) at %06x\n", data, CPU_GetCSPC());

return data;
}


// Send data to IO port C
void GPIO_SetIOC(uint16_t data, uint16_t mask) {
// printf("write to IOC with %04x at %06x\n", data, CPU_GetCSPC());
// printf("Write to IOC with %04x at %06x\n", data, CPU_GetCSPC());

if ((mask >> 8) & 1) {
Controller_SetSelect(0, (data >> 8) & 1);
Expand Down
10 changes: 5 additions & 5 deletions src/core/hw/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void Misc_SetIRQFlags(uint16_t addr, uint16_t data) {
} else if (addr == 0x2863) {
PPU_SetIRQFlags(data);
} else {
VSmile_Warning("unknown IRQ Acknowledge for %04x with data %04x", addr, data);
VSmile_Warning("Unknown IRQ Acknowledge for %04x with data %04x", addr, data);
}

// switch (address) {
Expand All @@ -156,7 +156,7 @@ void Misc_SetIRQFlags(uint16_t addr, uint16_t data) {
// this.io[0x22] |= data;
// break;
// default:
// VSmile_Warning("unknown IRQ Acknowledge for %04x with data %04x", address, data);
// VSmile_Warning("Unknown IRQ Acknowledge for %04x with data %04x", address, data);
// }
//
// CPU_ActivatePendingIRQs(); // Notify CPU that there might be IRQ's to handle
Expand Down Expand Up @@ -226,7 +226,7 @@ void Misc_WriteADCCtrl(uint16_t data) {
if (data & prevADC & 0x2000) {
this.adcCtrl &= ~0x2000;
Bus_Store(0x3d22, 0x2000); // Reset interrupt in IRQ
// printf("resetting interrupt status...\n");
// printf("Resetting interrupt status...\n");
}

if (this.adcCtrl & 1) { // ADE
Expand All @@ -241,7 +241,7 @@ void Misc_WriteADCCtrl(uint16_t data) {
uint32_t ticks = 16 << ((data >> 2) & 3);
Timer_Adjust(this.adcTimers[channel], ticks);
Timer_Reset(this.adcTimers[channel]);
// printf("conversion requested\n");
// printf("Conversion requested\n");
}

if (data & 0x0400) { // 8KHz Auto Request
Expand All @@ -255,7 +255,7 @@ void Misc_WriteADCCtrl(uint16_t data) {
Timer_Adjust(this.adcTimers[i], 0);
Timer_Reset(this.adcTimers[i]);
}
// printf("conversion timers disabled\n");
// printf("Conversion timers disabled\n");
}
}

Expand Down
Loading