Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
noahwooten05 committed Nov 18, 2023
1 parent 3be935a commit bfca78e
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 57 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "8BD496AF-9858-4E38-8B37-FBC89DD0433B"
type = "1"
version = "2.0">
</Bucket>
File renamed without changes.
6 changes: 4 additions & 2 deletions plasm2_emu/cpu/cpu.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "../basetypes.h"
#include <time.h>

/*
cpu.h
plasm2
Expand Down Expand Up @@ -148,7 +149,7 @@ extern void(*Instructions[256])(void);
#define REGCOUNT_SPEC 16
#define REGCOUNT_TOTAL REGCOUNT_GPRS + REGCOUNT_SPEC

struct {
typedef struct _PLASM2_CTX {
union {
union {
u64 rs_64[REGCOUNT_TOTAL];
Expand Down Expand Up @@ -203,7 +204,8 @@ struct {
}pti;
};
};
}i[1];
}PLASM2_CTX, *PPLASM2_CTX;
extern PPLASM2_CTX i;

void cpui_csm_set(u64 Handler);
void cpui_csm_msg(byte Code, u64 AddtData);
Expand Down
5 changes: 2 additions & 3 deletions plasm2_emu/cpu/cpu_inst.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void cpui_inst_cll(u64 Address) {
SecurityPacket.Flags = (u32)i->flags;
SecurityPacket.SecurityLevel = i->security_s.SecurityLevel;
mmu_push(SecurityPacket.Raw);
i->flags_s.SF = 1;
i->flags_s.SF = 1;
i->ip = Address;
i->flags_s.CF = 1;
return;
Expand Down Expand Up @@ -71,7 +71,6 @@ void cpui_inst_int(byte Interrupt) {
u64* InterruptTable = (u64*)((byte*)cpuctx->PhysicalMemory + i->pti.it); // PM usage good (reason: pti.it is a secure register)
u64 VirtualAddress = InterruptTable[Interrupt];
byte SecurityLevel = (byte)((VirtualAddress & 0xFF00000000000000LLU) >> 56LLU);
byte BackupLevel = i->security_s.SecurityLevel;
i->security_s.SecurityLevel = SecurityLevel;
u64 PhysicalAddress = mmu_translate(VirtualAddress & 0x00FFFFFFFFFFFFFF, REASON_EXEC | REASON_READ, SIZE_WATCHDOG);
if (!PhysicalAddress) {
Expand All @@ -96,4 +95,4 @@ void cpui_inst_int(byte Interrupt) {
i->flags_s.SF = 1;
i->ip = PhysicalAddress;
return;
}
}
4 changes: 2 additions & 2 deletions plasm2_emu/cpu/mmu/mmu_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ void mmu_put1(u64 Address, byte Value) {
}

void mmu_put4(u64 Address, u32 Value) {
u32* PhysicalBytes = (byte*)((byte*)cpuctx->PhysicalMemory + Address); // PM usage good (reason: comes from trust)
u32* PhysicalBytes = (u32*)((byte*)cpuctx->PhysicalMemory + Address); // PM usage good (reason: comes from trust)
if (Address > PHYS_MEMSZ)
i->flags_s.XF = 1;
else
PhysicalBytes[0] = Value;
return;
}
}
4 changes: 2 additions & 2 deletions plasm2_emu/devices/fdisk/fdisk_init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "fdisk.h"
#include "../cpu/cpu.h"
#include "../../cpu/cpu.h"
#include <stdlib.h>
#include <string.h>
/*
Expand Down Expand Up @@ -105,4 +105,4 @@ void fdisk_clock(void) {
}

// write cache
}
}
4 changes: 2 additions & 2 deletions plasm2_emu/devices/fdisk/fdisk_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void fdiski_drivegetvendorsz(int DriveId, u64 Pointer) {
return;

u64 RPointer = mmu_translate(Pointer, REASON_WRTE, 16);
char* TPointer = ((byte*)cpuctx->PhysicalMemory + RPointer);
byte* TPointer = ((byte*)cpuctx->PhysicalMemory + RPointer);
memcpy(TPointer, fdiskctx->Drives[DriveId].DeviceVendor, 16);

return;
Expand Down Expand Up @@ -283,4 +283,4 @@ void fdiski_drivewritestack(int DriveId, u64 Data) {
fdiskctx->Drives[DriveId].CurrentFilePointer = CFPBackup;

return;
}
}
6 changes: 3 additions & 3 deletions plasm2_emu/devices/sdbg/sdbg_init.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "sdbg.h"
#include "../emu.h"
#include "../cpu/cpu.h"
#include "../../emu.h"
#include "../../cpu/cpu.h"
#include <stdlib.h>
#include <string.h>
/*
Expand Down Expand Up @@ -61,4 +61,4 @@ void sdbg_collect(void) {
devicesctx->DeviceCount++;

return;
}
}
6 changes: 3 additions & 3 deletions plasm2_emu/devices/sdbg/sdbg_natives.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "sdbg.h"
#include "../cpu/cpu.h"
#include "../cpu/mmu/mmu.h"
#include "../../cpu/cpu.h"
#include "../../cpu/mmu/mmu.h"
#include <string.h>
/*
sdbg_natives.c
Expand Down Expand Up @@ -30,4 +30,4 @@ void sdbg_setsendloc(u64 Location) {
void sdbg_setsendsz(u64 Size) {
sdbgctx->VirtualSize = Size;
return;
}
}
3 changes: 1 addition & 2 deletions plasm2_emu/devices/video/video_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ byte PauseDrawing;
videoctx_t* videoctx;
SDL_Thread* LoopThread;


#pragma warning(disable: 6011 6387)

void videoii_loop(void);
Expand Down Expand Up @@ -67,4 +66,4 @@ void videoii_loop(void) {
SDL_RenderPresent(Renderer);
SDL_Delay(16);
}
}
}
28 changes: 17 additions & 11 deletions plasm2_emu/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
#include "psin2/psin2.h"
#include "decoder/decoder.h"
#include "tools/tools.h"

#pragma warning(disable: 6308 6387 26451 28182)

/*
main.c
plasm2
plasm2_emu
(c) Noah Wooten 2023, All Rights Reserved
*/
*/

/*
Starting physical memory map:
Expand All @@ -34,8 +33,11 @@ Starting physical memory map:
0x25F0: End of stack
*/

int __t_argc;
char** __t_argv;
PPLASM2_CTX i;

int main(int argc, char** argv) {
//fgetc(stdin);
FILE* a = freopen("rstd", "w", stdout);

emu_init();
Expand All @@ -44,7 +46,7 @@ int main(int argc, char** argv) {
char** FixedDisks = NULL;
int FixedDiskCount = 0;

for (int i = 0; i < argc; i++) {
for (int i = 1; i < argc; i++) {
if (strstr(argv[i], "-d") || strstr(argv[i], "--debug")) {
emuctx->DebuggerEnabled = 1;
}
Expand All @@ -60,7 +62,7 @@ int main(int argc, char** argv) {
printf("Misc Switches: (General Function Only)\n\n");
printf("%s -d | --debug : Enables disassembler / debugger mode.\n", argv[0]);
printf("%s -h | --help : Shows this screen.\n", argv[0]);
printf("\nBy default, PLASM2Emu accepts a properly formed 'bios.bin'.\n");
return 0;
}
Expand All @@ -75,15 +77,18 @@ int main(int argc, char** argv) {
FixedDiskCount++;
}
if (strstr(argv[i], "-t") || strstr(argv[i], "--tools")) {
__t_argc = argc;
__t_argv = argv;
tools_main();
return 0;
}
}

cpu_init();

i = malloc(sizeof(PLASM2_CTX));
memset(i, 0, sizeof(*i));

cpu_init();

i->pti.dvptr = 0x0000;
i->ip = 0x03A0;
i->pti.slb = 0x24F0;
Expand Down Expand Up @@ -158,11 +163,12 @@ int main(int argc, char** argv) {
printf("CPU Halted.\n");

printf("Total Clocks: %llu\n", ClockCnt);
time_t Diff = (Startdown - Startup) + 1;
printf("Total Time: %llum %llus\n", Diff / 60, Diff % 60);
time_t Diff = (Startdown - Startup) + 1;
printf("Total Time: %ldm %lds\n", Diff / 60, Diff % 60);
printf("Clocks Per Sec: %llu\n", (ClockCnt) / (Diff));

fclose(a);

free(i);

return 0;
}
}
3 changes: 1 addition & 2 deletions plasm2_emu/psin2/psin2_data.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "psin2.h"
/*
psin2_data.c
Expand Down Expand Up @@ -96,4 +95,4 @@ void psin2_load(void) {
psin2_parse("__SIT = 0x96, // SIT 96 (R:04,08 IHNDLR) 16 : Set Interrupt Table");

return;
}
}
3 changes: 1 addition & 2 deletions plasm2_emu/psin2/psin2_parse.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -146,4 +145,4 @@ int psin2_parse(const char* InstructionData) {

int psin2_getcnt(void) {
return psin2ctx->InstructionCount;
}
}
5 changes: 4 additions & 1 deletion plasm2_emu/tools/tools_bootldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ typedef struct _bootimg {
#define BOOTLDRFLAG_SAVE 0x01
#define BOOTLDRFLAG_LOAD 0x02

extern int __t_argc;
extern char** __t_argv;

void toolsi_bootloader(void) {
char* Strbuf = malloc(240);

Expand Down Expand Up @@ -161,4 +164,4 @@ void toolsi_bootloader(void) {

printf("Success!\n");
return;
}
}
37 changes: 17 additions & 20 deletions plasm2_emu/tools/tools_fontgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ plasm2_emu
(c) Noah Wooten 2023, All Rights Reserved
*/

SDL_Window* Window;
SDL_Renderer* Renderer;

#pragma warning(disable: 6011)

#define SINGLE_GET(Single, Bit) (Single & (1LLU << Bit)) >> Bit
Expand Down Expand Up @@ -79,8 +76,8 @@ void toolsi_fontgen(void) {
return;
}

SDL_Window* Window = SDL_CreateWindow("PLASM2 Font Generator", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 257, 640, 0);
SDL_Renderer* Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED);
SDL_Window* FontWindow = SDL_CreateWindow("PLASM2 Font Generator", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 257, 640, 0);
SDL_Renderer* FontRenderer = SDL_CreateRenderer(FontWindow, -1, SDL_RENDERER_ACCELERATED);

char Quit = 0;
while (!Quit) {
Expand Down Expand Up @@ -111,19 +108,19 @@ void toolsi_fontgen(void) {
if (Quit)
break;

SDL_SetRenderDrawColor(Renderer, 0, 0, 0, 255);
SDL_RenderClear(Renderer);
SDL_SetRenderDrawColor(FontRenderer, 0, 0, 0, 255);
SDL_RenderClear(FontRenderer);

SDL_SetRenderDrawColor(Renderer, 200, 200, 200, 255);
SDL_SetRenderDrawColor(FontRenderer, 200, 200, 200, 255);
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 16; y++) {
SDL_Rect Rectangle = { (x * 32) + 1, (y * 32) + 1, 31, 31 };
if (Bitmap[CurrentChar][(y * 8) + x]) {
SDL_SetRenderDrawColor(Renderer, 220, 220, 220, 255);
SDL_RenderFillRect(Renderer, &Rectangle);
SDL_SetRenderDrawColor(Renderer, 200, 200, 200, 255);
SDL_SetRenderDrawColor(FontRenderer, 220, 220, 220, 255);
SDL_RenderFillRect(FontRenderer, &Rectangle);
SDL_SetRenderDrawColor(FontRenderer, 200, 200, 200, 255);
}
SDL_RenderDrawRect(Renderer, &Rectangle);
SDL_RenderDrawRect(FontRenderer, &Rectangle);
if (InRange(MousePos[0], Rectangle.x, Rectangle.x + Rectangle.w)) {
if (InRange(MousePos[1], Rectangle.y, Rectangle.y + Rectangle.h)) {
if (IsMouseDown[0])
Expand All @@ -136,8 +133,8 @@ void toolsi_fontgen(void) {
}
for (int b = 0; b < 2; b++) {
SDL_Rect Rectangle = { 1 + (1 * b) + (127 * b), 523, 128, 127 };
SDL_SetRenderDrawColor(Renderer, 200, 200, 200, 255);
SDL_RenderDrawRect(Renderer, &Rectangle);
SDL_SetRenderDrawColor(FontRenderer, 200, 200, 200, 255);
SDL_RenderDrawRect(FontRenderer, &Rectangle);

if (InRange(MousePos[0], Rectangle.x, Rectangle.x + Rectangle.w)) {
if (InRange(MousePos[1], Rectangle.y, Rectangle.y + Rectangle.h) && IsMouseDown[0]) {
Expand All @@ -151,11 +148,11 @@ void toolsi_fontgen(void) {
}

if (b) {
SDL_RenderDrawLine(Renderer, Rectangle.x + 20, Rectangle.y + 20, Rectangle.x + 107, Rectangle.y + 64);
SDL_RenderDrawLine(Renderer, Rectangle.x + 107, Rectangle.y + 64, Rectangle.x + 20, Rectangle.y + 97);
SDL_RenderDrawLine(FontRenderer, Rectangle.x + 20, Rectangle.y + 20, Rectangle.x + 107, Rectangle.y + 64);
SDL_RenderDrawLine(FontRenderer, Rectangle.x + 107, Rectangle.y + 64, Rectangle.x + 20, Rectangle.y + 97);
} else {
SDL_RenderDrawLine(Renderer, Rectangle.x + 20, Rectangle.y + 64, Rectangle.x + 107, Rectangle.y + 97);
SDL_RenderDrawLine(Renderer, Rectangle.x + 20, Rectangle.y + 64, Rectangle.x + 107, Rectangle.y + 20);
SDL_RenderDrawLine(FontRenderer, Rectangle.x + 20, Rectangle.y + 64, Rectangle.x + 107, Rectangle.y + 97);
SDL_RenderDrawLine(FontRenderer, Rectangle.x + 20, Rectangle.y + 64, Rectangle.x + 107, Rectangle.y + 20);
}
}

Expand All @@ -178,7 +175,7 @@ void toolsi_fontgen(void) {
}
}

SDL_RenderPresent(Renderer);
SDL_RenderPresent(FontRenderer);
SDL_Delay(10);
}

Expand All @@ -193,4 +190,4 @@ void toolsi_fontgen(void) {
}

return;
}
}
4 changes: 2 additions & 2 deletions plasm2_emu/tools/tools_hddgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void toolsi_hddgen(void) {
memset(FdHdr, 0, sizeof(fdiskhdr_t));

FdHdr->Magic = FDISKHDR_MAGIC;
srand((u32)time(NULL));
srand(time(NULL) & 0xFFFFFFFF);
FdHdr->DeviceSerial = rand();
FdHdr->DeviceVendorId = 0x4273;
strcpy(FdHdr->DeviceVendor, "PLASM2 HDDGnr8r");
Expand All @@ -139,4 +139,4 @@ void toolsi_hddgen(void) {

printf(" Successfully wrote HDD file.\n");
return;
}
}

0 comments on commit bfca78e

Please sign in to comment.