From 8dcf19d2e16f468e1d5854110df536e010f7c2b7 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Thu, 15 Aug 2019 15:21:45 -0700 Subject: [PATCH] Add namespaces to vars and make chip define headers subfiles of there chips --- qtBuildSystem/Mu/Mu.pro | 8 +-- src/dbvz.c | 2 +- ...zRegisterNames.h => dbvzRegisterNames.c.h} | 6 --- src/pdiUsbD12.c | 2 +- ...mmandNames.h => pdiUsbD12CommandNames.c.h} | 4 -- src/sdCard.c | 2 +- ...dCommandNames.h => sdCardCommandNames.c.h} | 4 -- src/sed1376.c | 52 +++++++++---------- src/sed1376Accessors.c.h | 42 +++++++-------- ...gisterNames.h => sed1376RegisterNames.c.h} | 4 -- 10 files changed, 54 insertions(+), 72 deletions(-) rename src/{dbvzRegisterNames.h => dbvzRegisterNames.c.h} (98%) rename src/{pdiUsbD12CommandNames.h => pdiUsbD12CommandNames.c.h} (86%) rename src/{sdCardCommandNames.h => sdCardCommandNames.c.h} (97%) rename src/{sed1376RegisterNames.h => sed1376RegisterNames.c.h} (96%) diff --git a/qtBuildSystem/Mu/Mu.pro b/qtBuildSystem/Mu/Mu.pro index 9308bad..dfefb23 100644 --- a/qtBuildSystem/Mu/Mu.pro +++ b/qtBuildSystem/Mu/Mu.pro @@ -239,7 +239,7 @@ HEADERS += \ ../../src/audio/blip_buf.h \ ../../src/dbvz.h \ ../../src/dbvzRegisterAccessors.c.h \ - ../../src/dbvzRegisterNames.h \ + ../../src/dbvzRegisterNames.c.h \ ../../src/dbvzTiming.c.h \ ../../src/debug/sandbox.h \ ../../src/debug/sandboxTrapNumToName.c.h \ @@ -254,15 +254,15 @@ HEADERS += \ ../../src/m68k/m68kexternal.h \ ../../src/m68k/m68kops.h \ ../../src/pdiUsbD12.h \ - ../../src/pdiUsbD12CommandNames.h \ + ../../src/pdiUsbD12CommandNames.c.h \ ../../src/portability.h \ ../../src/sdCard.h \ ../../src/sdCardAccessors.c.h \ - ../../src/sdCardCommandNames.h \ + ../../src/sdCardCommandNames.c.h \ ../../src/sdCardCrcTables.c.h \ ../../src/sed1376.h \ ../../src/sed1376Accessors.c.h \ - ../../src/sed1376RegisterNames.h \ + ../../src/sed1376RegisterNames.c.h \ ../../src/silkscreen.h \ debugviewer.h \ emuwrapper.h \ diff --git a/src/dbvz.c b/src/dbvz.c index 0ad5ff0..1bd6d34 100644 --- a/src/dbvz.c +++ b/src/dbvz.c @@ -13,7 +13,7 @@ #include "dbvz.h" -#include "dbvzRegisterNames.h" +#include "dbvzRegisterNames.c.h" dbvz_chip_t dbvzChipSelects[DBVZ_CHIP_END]; diff --git a/src/dbvzRegisterNames.h b/src/dbvzRegisterNames.c.h similarity index 98% rename from src/dbvzRegisterNames.h rename to src/dbvzRegisterNames.c.h index 19fb963..f30eeab 100644 --- a/src/dbvzRegisterNames.h +++ b/src/dbvzRegisterNames.c.h @@ -1,8 +1,4 @@ -#ifndef DBVZ_REGISTER_NAMES_H -#define DBVZ_REGISTER_NAMES_H - /*Dragonball VZ Register Definitions*/ -#define HW_REG_ADDR(x) (0xFFFFF000 | (x)) /*SIM - System Integration Module*/ #define SCR 0x000/*System Control Register*/ @@ -176,5 +172,3 @@ #define DRAMMC 0xC00/*DRAM Memory Configuration Register*/ #define DRAMC 0xC02/*DRAM Control Register*/ #define SDCTRL 0xC04/*SDRAM Control Register*/ - -#endif diff --git a/src/pdiUsbD12.c b/src/pdiUsbD12.c index afeb8fe..c582275 100644 --- a/src/pdiUsbD12.c +++ b/src/pdiUsbD12.c @@ -10,7 +10,7 @@ //running a new command before finishing the previous one will result in corruption -#include "pdiUsbD12CommandNames.h" +#include "pdiUsbD12CommandNames.c.h" #define PDIUSBD12_CMD_NONE 0xFF #define PDIUSBD12_TRANSFER_BUFFER_SIZE 131 diff --git a/src/pdiUsbD12CommandNames.h b/src/pdiUsbD12CommandNames.c.h similarity index 86% rename from src/pdiUsbD12CommandNames.h rename to src/pdiUsbD12CommandNames.c.h index 9854992..08a14ce 100644 --- a/src/pdiUsbD12CommandNames.h +++ b/src/pdiUsbD12CommandNames.c.h @@ -1,5 +1,3 @@ -#ifndef PDI_USB_D12_COMMAND_NAMES_H -#define PDI_USB_D12_COMMAND_NAMES_H /*PDIUSBD12 Commands*/ #define SELECT_ENDPOINT_CTRL_OUT 0x00 @@ -19,5 +17,3 @@ #define READ_INTERRUPT_REGISTER 0xF4 #define SET_DMA 0xFB - -#endif diff --git a/src/sdCard.c b/src/sdCard.c index 11f777f..ee3777a 100644 --- a/src/sdCard.c +++ b/src/sdCard.c @@ -6,7 +6,7 @@ #include "portability.h" -#include "sdCardCommandNames.h" +#include "sdCardCommandNames.c.h" #include "sdCardCrcTables.c.h" diff --git a/src/sdCardCommandNames.h b/src/sdCardCommandNames.c.h similarity index 97% rename from src/sdCardCommandNames.h rename to src/sdCardCommandNames.c.h index faa4fe8..9da7e7f 100644 --- a/src/sdCardCommandNames.h +++ b/src/sdCardCommandNames.c.h @@ -1,5 +1,3 @@ -#ifndef SD_CARD_COMMAND_NAMES_H -#define SD_CARD_COMMAND_NAMES_H /*SD Card Commands*/ /*Command Format:01IIIIIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCC1*/ /*48 bits, I = index, A = argument, C = CRC*/ @@ -63,5 +61,3 @@ #define DR_ACCEPTED 0x05 #define DR_CRC_ERROR 0x0B #define DR_WRITE_ERROR 0x0D - -#endif diff --git a/src/sed1376.c b/src/sed1376.c index e7925c1..9cc1736 100644 --- a/src/sed1376.c +++ b/src/sed1376.c @@ -21,7 +21,7 @@ //The LCD power-off sequence is activated by programming the Power Save Mode Enable bit (REG[A0h] bit 0) to 1. -#include "sed1376RegisterNames.h" +#include "sed1376RegisterNames.c.h" uint16_t* sed1376Framebuffer; @@ -32,46 +32,46 @@ static uint8_t sed1376RLut[0x100]; static uint8_t sed1376GLut[0x100]; static uint8_t sed1376BLut[0x100]; static uint16_t sed1376OutputLut[0x100];//used to speed up pixel conversion -static uint32_t screenStartAddress; -static uint16_t lineSize; -static uint16_t (*renderPixel)(uint16_t x, uint16_t y); +static uint32_t sed1376ScreenStartAddress; +static uint16_t sed1376LineSize; +static uint16_t (*sed1376RenderPixel)(uint16_t x, uint16_t y); #include "sed1376Accessors.c.h" -static uint32_t getBufferStartAddress(void){ - uint32_t screenStartAddress = sed1376Registers[DISP_ADDR_2] << 16 | sed1376Registers[DISP_ADDR_1] << 8 | sed1376Registers[DISP_ADDR_0]; +static uint32_t sed1376GetBufferStartAddress(void){ + uint32_t sed1376ScreenStartAddress = sed1376Registers[DISP_ADDR_2] << 16 | sed1376Registers[DISP_ADDR_1] << 8 | sed1376Registers[DISP_ADDR_0]; switch((sed1376Registers[SPECIAL_EFFECT] & 0x03) * 90){ case 0: //desired byte address / 4. - screenStartAddress *= 4; + sed1376ScreenStartAddress *= 4; break; case 90: //((desired byte address + (panel height * bpp / 8)) / 4) - 1. - screenStartAddress += 1; - screenStartAddress *= 4; - //screenStartAddress - (panelHeight * bpp / 8); + sed1376ScreenStartAddress += 1; + sed1376ScreenStartAddress *= 4; + //sed1376ScreenStartAddress - (panelHeight * bpp / 8); break; case 180: //((desired byte address + (panel width * panel height * bpp / 8)) / 4) - 1. - screenStartAddress += 1; - screenStartAddress *= 4; - //screenStartAddress - (panelWidth * panelHeight * bpp / 8); + sed1376ScreenStartAddress += 1; + sed1376ScreenStartAddress *= 4; + //sed1376ScreenStartAddress - (panelWidth * panelHeight * bpp / 8); break; case 270: //(desired byte address + ((panel width - 1) * panel height * bpp / 8)) / 4. - screenStartAddress *= 4; - //screenStartAddress -= ((panelWidth - 1) * panelHeight * bpp / 8); + sed1376ScreenStartAddress *= 4; + //sed1376ScreenStartAddress -= ((panelWidth - 1) * panelHeight * bpp / 8); break; } - return screenStartAddress; + return sed1376ScreenStartAddress; } -static uint32_t getPipStartAddress(void){ +static uint32_t sed1376GetPipStartAddress(void){ uint32_t pipStartAddress = sed1376Registers[PIP_ADDR_2] << 16 | sed1376Registers[PIP_ADDR_1] << 8 | sed1376Registers[PIP_ADDR_0]; switch((sed1376Registers[SPECIAL_EFFECT] & 0x03) * 90){ case 0: @@ -114,7 +114,7 @@ void sed1376Reset(void){ palmMisc.backlightLevel = 0; palmMisc.lcdOn = false; - renderPixel = NULL; + sed1376RenderPixel = NULL; sed1376Registers[REV_CODE] = 0x28; sed1376Registers[DISP_BUFF_SIZE] = 0x14; @@ -358,19 +358,19 @@ void sed1376Render(void){ uint16_t rotation = 90 * (sed1376Registers[SPECIAL_EFFECT] & 0x03); uint32_t index; - screenStartAddress = getBufferStartAddress(); - lineSize = (sed1376Registers[LINE_SIZE_1] << 8 | sed1376Registers[LINE_SIZE_0]) * 4; + sed1376ScreenStartAddress = sed1376GetBufferStartAddress(); + sed1376LineSize = (sed1376Registers[LINE_SIZE_1] << 8 | sed1376Registers[LINE_SIZE_0]) * 4; selectRenderer(color, bitDepth); - if(renderPixel){ + if(sed1376RenderPixel){ uint16_t pixelX; uint16_t pixelY; MULTITHREAD_DOUBLE_LOOP(pixelX, pixelY) for(pixelY = 0; pixelY < 160; pixelY++) for(pixelX = 0; pixelX < 160; pixelX++) - sed1376Framebuffer[pixelY * 160 + pixelX] = renderPixel(pixelX, pixelY); + sed1376Framebuffer[pixelY * 160 + pixelX] = sed1376RenderPixel(pixelX, pixelY); - //debugLog("Screen start address:0x%08X, buffer width:%d, swivel view:%d degrees\n", screenStartAddress, lineSize, rotation); + //debugLog("Screen start address:0x%08X, buffer width:%d, swivel view:%d degrees\n", sed1376ScreenStartAddress, lineSize, rotation); //debugLog("Screen format, color:%s, BPP:%d\n", boolString(color), bitDepth); if(pictureInPictureEnabled){ @@ -392,11 +392,11 @@ void sed1376Render(void){ if(pipStartX < 160 && pipStartY < 160){ pipEndX = FAST_MIN(pipEndX, 160); pipEndY = FAST_MIN(pipEndY, 160); - screenStartAddress = getPipStartAddress(); - lineSize = (sed1376Registers[PIP_LINE_SZ_1] << 8 | sed1376Registers[PIP_LINE_SZ_0]) * 4; + sed1376ScreenStartAddress = sed1376GetPipStartAddress(); + sed1376LineSize = (sed1376Registers[PIP_LINE_SZ_1] << 8 | sed1376Registers[PIP_LINE_SZ_0]) * 4; MULTITHREAD_DOUBLE_LOOP(pixelX, pixelY) for(pixelY = pipStartY; pixelY < pipEndY; pixelY++) for(pixelX = pipStartX; pixelX < pipEndX; pixelX++) - sed1376Framebuffer[pixelY * 160 + pixelX] = renderPixel(pixelX, pixelY); + sed1376Framebuffer[pixelY * 160 + pixelX] = sed1376RenderPixel(pixelX, pixelY); } } diff --git a/src/sed1376Accessors.c.h b/src/sed1376Accessors.c.h index 3cced05..4aa15aa 100644 --- a/src/sed1376Accessors.c.h +++ b/src/sed1376Accessors.c.h @@ -30,85 +30,85 @@ static uint16_t lutMonochromeValue(uint8_t lutIndex){ //monochrome static uint16_t get1BppMonochrome(uint16_t x, uint16_t y){ - return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x / 8)] >> (7 - x % 8) & 0x01); + return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x / 8)] >> (7 - x % 8) & 0x01); } static uint16_t get2BppMonochrome(uint16_t x, uint16_t y){ - return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x / 4)] >> (6 - x % 4 * 2) & 0x03); + return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x / 4)] >> (6 - x % 4 * 2) & 0x03); } static uint16_t get4BppMonochrome(uint16_t x, uint16_t y){ - return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x / 2)] >> (4 - x % 2 * 4) & 0x0F); + return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x / 2)] >> (4 - x % 2 * 4) & 0x0F); } static uint16_t get8BppMonochrome(uint16_t x, uint16_t y){ - return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x)]); + return lutMonochromeValue(sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x)]); } static uint16_t get16BppMonochrome(uint16_t x, uint16_t y){ - uint16_t pixelValue = sed1376Ram[handlePanelDataSwaps(screenStartAddress + (y * lineSize + x) * 2)] << 8 | sed1376Ram[handlePanelDataSwaps(screenStartAddress + (y * lineSize + x) * 2 + 1)]; + uint16_t pixelValue = sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + (y * sed1376LineSize + x) * 2)] << 8 | sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + (y * sed1376LineSize + x) * 2 + 1)]; return makeRgb16FromGreenComponent(pixelValue); } //color static uint16_t get1BppColor(uint16_t x, uint16_t y){ - return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x / 8)] >> (7 - x % 8) & 0x01]; + return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x / 8)] >> (7 - x % 8) & 0x01]; } static uint16_t get2BppColor(uint16_t x, uint16_t y){ - return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x / 4)] >> (6 - x % 4 * 2) & 0x03]; + return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x / 4)] >> (6 - x % 4 * 2) & 0x03]; } static uint16_t get4BppColor(uint16_t x, uint16_t y){ - return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x / 2)] >> (4 - x % 2 * 4) & 0x0F]; + return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x / 2)] >> (4 - x % 2 * 4) & 0x0F]; } static uint16_t get8BppColor(uint16_t x, uint16_t y){ - return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(screenStartAddress + y * lineSize + x)]]; + return sed1376OutputLut[sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + y * sed1376LineSize + x)]]; } static uint16_t get16BppColor(uint16_t x, uint16_t y){ //this format is little endian, to use big endian data sed1376Registers[SPECIAL_EFFECT] & 0x40 must be set - return sed1376Ram[handlePanelDataSwaps(screenStartAddress + (y * lineSize + x * 2) + 1)] << 8 | sed1376Ram[handlePanelDataSwaps(screenStartAddress + (y * lineSize + x * 2))]; + return sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + (y * sed1376LineSize + x * 2) + 1)] << 8 | sed1376Ram[handlePanelDataSwaps(sed1376ScreenStartAddress + (y * sed1376LineSize + x * 2))]; } static void selectRenderer(bool color, uint8_t bpp){ - renderPixel = NULL; + sed1376RenderPixel = NULL; if(color){ switch(bpp){ case 1: - renderPixel = get1BppColor; + sed1376RenderPixel = get1BppColor; break; case 2: - renderPixel = get2BppColor; + sed1376RenderPixel = get2BppColor; break; case 4: - renderPixel = get4BppColor; + sed1376RenderPixel = get4BppColor; break; case 8: - renderPixel = get8BppColor; + sed1376RenderPixel = get8BppColor; break; case 16: - renderPixel = get16BppColor; + sed1376RenderPixel = get16BppColor; break; } } else{ switch(bpp){ case 1: - renderPixel = get1BppMonochrome; + sed1376RenderPixel = get1BppMonochrome; break; case 2: - renderPixel = get2BppMonochrome; + sed1376RenderPixel = get2BppMonochrome; break; case 4: - renderPixel = get4BppMonochrome; + sed1376RenderPixel = get4BppMonochrome; break; case 8: - renderPixel = get8BppMonochrome; + sed1376RenderPixel = get8BppMonochrome; break; case 16: - renderPixel = get16BppMonochrome; + sed1376RenderPixel = get16BppMonochrome; break; } } diff --git a/src/sed1376RegisterNames.h b/src/sed1376RegisterNames.c.h similarity index 96% rename from src/sed1376RegisterNames.h rename to src/sed1376RegisterNames.c.h index 7e688e9..1c33152 100644 --- a/src/sed1376RegisterNames.h +++ b/src/sed1376RegisterNames.c.h @@ -1,5 +1,3 @@ -#ifndef SED1376_REGISTER_NAMES_H -#define SED1376_REGISTER_NAMES_H /*SED1376 Register Definitions*/ /*Read-Only Configuration Registers*/ @@ -83,5 +81,3 @@ #define PWM_CONFIG 0xB1 #define PWM_LENGTH 0xB2 #define PWM_DUTY_CYCLE 0xB3 - -#endif