修复nes颜色错误问题
This commit is contained in:
@@ -7,14 +7,14 @@ set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O3 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE}
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-mcpu=${CONFIG_ARCH} -O3 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mthumb-interwork -D=MKRTOS -std=c++11 \
|
||||
set(CMAKE_CXX_FLAGS "-mcpu=${CONFIG_ARCH} -O3 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -D=MKRTOS -std=c++11 \
|
||||
-fmessage-length=0 -Xlinker --print-map -Wall -W -fno-stack-protector -g \
|
||||
-u=_printf_float -D__ARM_ARCH_7M__ \
|
||||
-ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -O3 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mthumb-interwork -D=MKRTOS \
|
||||
set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -O3 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -D=MKRTOS \
|
||||
-u=_printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \
|
||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector -D__ARM_ARCH_7M__ \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAT32F437ZMT7 -DUSE_STDPERIPH_DRIVER -DAT_SURF_F437_V1 ")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DAT32F437ZMT7 -DUSE_STDPERIPH_DRIVER -DAT_SURF_F437_V1 ")
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -DAT32F437ZMT7 -DUSE_STDPERIPH_DRIVER -DAT_SURF_F437_V1 ")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAT32F437ZMT7 -DUSE_STDPERIPH_DRIVER -DAT_SURF_F437_V1 -DINFONES")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DAT32F437ZMT7 -DUSE_STDPERIPH_DRIVER -DAT_SURF_F437_V1 -DINFONES")
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -DAT32F437ZMT7 -DUSE_STDPERIPH_DRIVER -DAT_SURF_F437_V1 -DINFONES")
|
||||
|
||||
file(
|
||||
GLOB deps
|
||||
@@ -14,7 +14,6 @@ file(
|
||||
# ${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/NES_Simulator/PPU.c
|
||||
# ${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/NES_Simulator/ROM__MARIO.c
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/infoNES/*.c
|
||||
# ${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/infoNES/mapper/*.c
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/infoNES/ports/*.c
|
||||
*.c
|
||||
)
|
||||
@@ -51,6 +50,7 @@ target_include_directories(
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_bsp/AT32/AT32F435_437_Firmware_Library_V2.2.0/project/at_surf_f437_board/
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_bsp/AT32/AT32F435_437_Firmware_Library_V2.2.0/middlewares/i2c_application_library
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator
|
||||
|
||||
# ${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/NES_Simulator
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/infoNES
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/server/drv/ATSURFF437/nes_simulator/mapper
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// #define _USE_ROM_MARIO_
|
||||
#define _USE_ROM_MARIO_
|
||||
//#define _USE_ROM_DEMO_
|
||||
#define _USE_ROM_TANKE_
|
||||
// #define _USE_ROM_TANKE_
|
||||
|
||||
#ifdef _USE_ROM_MARIO_
|
||||
char const rom_file[]={78,69,83,26,2,1,1,0,0,0,0,0,0,0,0,0,
|
||||
|
||||
@@ -29,56 +29,65 @@ void NesFrameCycle(void)
|
||||
|
||||
//// ?????????????????VROM????????????0???????VROM
|
||||
// if ( NesHeader.byVRomSize == 0)
|
||||
// ????VROM?<3F><>??<3F><>?<3F><>?
|
||||
// ????VROM?<3F><>??<3F><>?<3F><>?
|
||||
FrameCnt = 0;
|
||||
while(Continue){
|
||||
/* scanline: 0~19 VBANK ?<3F><>???PPU???NMI????????NMI ?<3F><>?, */
|
||||
while (Continue)
|
||||
{
|
||||
/* scanline: 0~19 VBANK ?<3F><>???PPU???NMI????????NMI ?<3F><>?, */
|
||||
FrameCnt++; //???????
|
||||
// printf("\r\n??????? %d", FrameCnt);
|
||||
SpriteHitFlag = FALSE;
|
||||
for(PPU_scanline=0; PPU_scanline<20; PPU_scanline++){
|
||||
for (PPU_scanline = 0; PPU_scanline < 20; PPU_scanline++)
|
||||
{
|
||||
exec6502(CLOCKS_PER_SCANLINE);
|
||||
// NesHBCycle();
|
||||
}
|
||||
/* scanline: 20, PPU??????????????<3F><>????????*/
|
||||
/* scanline: 20, PPU??????????????<3F><>????????*/
|
||||
exec6502(CLOCKS_PER_SCANLINE);
|
||||
// NesHBCycle(); //??????
|
||||
PPU_scanline++; // 20++
|
||||
PPU_Reg.R2 &= ~R2_SPR0_HIT;
|
||||
/* scanline: 21~261*/
|
||||
for(; PPU_scanline < SCAN_LINE_DISPALY_END_NUM; PPU_scanline++){
|
||||
if((SpriteHitFlag == TRUE) && ((PPU_Reg.R2 & R2_SPR0_HIT) == 0)){
|
||||
for (; PPU_scanline < SCAN_LINE_DISPALY_END_NUM; PPU_scanline++)
|
||||
{
|
||||
if ((SpriteHitFlag == TRUE) && ((PPU_Reg.R2 & R2_SPR0_HIT) == 0))
|
||||
{
|
||||
clocks = sprite[0].x * CLOCKS_PER_SCANLINE / NES_DISP_WIDTH;
|
||||
exec6502(clocks);
|
||||
PPU_Reg.R2 |= R2_SPR0_HIT;
|
||||
exec6502(CLOCKS_PER_SCANLINE - clocks);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
exec6502(CLOCKS_PER_SCANLINE);
|
||||
}
|
||||
|
||||
if(PPU_Reg.R1 & (R1_BG_VISIBLE | R1_SPR_VISIBLE)){ //????????????
|
||||
if (PPU_Reg.R1 & (R1_BG_VISIBLE | R1_SPR_VISIBLE))
|
||||
{ //????????????
|
||||
if (SpriteHitFlag == FALSE)
|
||||
NES_GetSpr0HitFlag(PPU_scanline - SCAN_LINE_DISPALY_START_NUM); //????Sprite #0 ??????
|
||||
}
|
||||
// if(FrameCnt & 2){ //?2???????
|
||||
if (FrameCnt & 2)
|
||||
{ //?2???????
|
||||
NES_RenderLine(PPU_scanline - SCAN_LINE_DISPALY_START_NUM); //?????????????
|
||||
// }
|
||||
}
|
||||
}
|
||||
/* scanline: 262 ?????*/
|
||||
exec6502(CLOCKS_PER_SCANLINE);
|
||||
PPU_Reg.R2 |= R2_VBlank_Flag; //????VBANK ???
|
||||
/*?????PPU VBANK?<3F><>????????VBANK*/
|
||||
if(PPU_Reg.R0 & R0_VB_NMI_EN){
|
||||
NMI_Flag = SET1; //???????<3F>k????NMI?<3F><>?
|
||||
/*?????PPU VBANK?<3F><>????????VBANK*/
|
||||
if (PPU_Reg.R0 & R0_VB_NMI_EN)
|
||||
{
|
||||
NMI_Flag = SET1; //???????<3F>k????NMI?<3F><>?
|
||||
}
|
||||
|
||||
/*?????IRQ????????????????APU??*/
|
||||
|
||||
/* A mapper function in V-Sync ?<3F><>???<3F><>????VBANK???*/
|
||||
/* A mapper function in V-Sync ?<3F><>???<3F><>????VBANK???*/
|
||||
// MapperVSync();
|
||||
|
||||
/*?????????JoyPad??,????JoyPad???????*/
|
||||
// NES_JoyPadUpdateValue(); //systick ?<3F><>????????
|
||||
// NES_JoyPadUpdateValue(); //systick ?<3F><>????????
|
||||
|
||||
/*?????????????????????*/
|
||||
// if(){
|
||||
@@ -100,34 +109,49 @@ void nes_main(void)
|
||||
/* ????NES??????????0x1A????????0x1a??Ctrl+Z,????????????????????
|
||||
* ???????strcncmp????3??????
|
||||
*/
|
||||
if(strncmp(neshreader->filetype, "NES", 3) != 0){
|
||||
printf("\r\n???<3F><>???????????????, NES??????????");
|
||||
if (strncmp(neshreader->filetype, "NES", 3) != 0)
|
||||
{
|
||||
printf("\r\n???<3F><>???????????????, NES??????????");
|
||||
return;
|
||||
}else{
|
||||
printf("\r\n?????????<3F><>?");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\r\n?????????<3F><>?");
|
||||
printf("\r\n 16kB ROM ?????: %d", neshreader->romnum);
|
||||
printf("\r\n 8kB VROM ?????: %d", neshreader->vromnum);
|
||||
if((neshreader->romfeature & 0x01) == 0){
|
||||
if ((neshreader->romfeature & 0x01) == 0)
|
||||
{
|
||||
printf("\r\n ??????");
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\r\n ???????");
|
||||
}
|
||||
|
||||
if((neshreader->romfeature & 0x02) == 0){
|
||||
if ((neshreader->romfeature & 0x02) == 0)
|
||||
{
|
||||
printf("\r\n ?????SRAM");
|
||||
}else{
|
||||
printf("\r\n ?<3F><>???SRAM");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\r\n ?<3F><>???SRAM");
|
||||
}
|
||||
|
||||
if((neshreader->romfeature & 0x04) == 0){
|
||||
if ((neshreader->romfeature & 0x04) == 0)
|
||||
{
|
||||
printf("\r\n ??512????trainer($7000-$71FF)");
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\r\n ??512????trainer(ROM?????????)");
|
||||
}
|
||||
|
||||
if((neshreader->romfeature & 0x08) == 0){
|
||||
if ((neshreader->romfeature & 0x08) == 0)
|
||||
{
|
||||
printf("\r\n 2???VRAM????");
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\r\n 4???VRAM????(??????)");
|
||||
}
|
||||
|
||||
@@ -139,9 +163,8 @@ void nes_main(void)
|
||||
*/
|
||||
init6502mem(0, /*exp_rom*/
|
||||
0, /*sram ??????????, ??????*/
|
||||
(&rom_file[0x10]), /*prg_rombank, ?<3F><>????<3F><> ??????????*/
|
||||
neshreader->romnum
|
||||
); //?????6502?<3F><>??????
|
||||
(&rom_file[0x10]), /*prg_rombank, ?<3F><>????<3F><> ??????????*/
|
||||
neshreader->romnum); //?????6502?<3F><>??????
|
||||
reset6502();
|
||||
PPU_Init((&rom_file[0x10] + (neshreader->romnum * 0x4000)), (neshreader->romfeature & 0x01)); /*PPU_?????*/
|
||||
NES_JoyPadInit();
|
||||
@@ -154,5 +177,4 @@ void nes_main(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*******************************END OF FILE***********************************/
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include "InfoNES.h"
|
||||
#include "InfoNES_System.h"
|
||||
#include <string.h>
|
||||
#include <u_types.h>
|
||||
// #include "UserMain.h"
|
||||
#include <at_surf_f437_board_lcd.h>
|
||||
|
||||
// #include <at_surf_f437_board_lcd.h>
|
||||
extern void nes_lcd_color_fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *color);
|
||||
/*-------------------------------------------------------------------*/
|
||||
/* Palette data */
|
||||
/*-------------------------------------------------------------------*/
|
||||
@@ -150,7 +151,7 @@ void InfoNES_LoadFrame()
|
||||
void InfoNES_LoadLine()
|
||||
{
|
||||
// BSP_LCD_DrawBitmap(32, PPU_Scanline, 256, 1, WorkLine);
|
||||
lcd_color_fill(32, PPU_Scanline, 32 + 256, PPU_Scanline, WorkLine);
|
||||
nes_lcd_color_fill(32, PPU_Scanline, 32 + 256, PPU_Scanline, WorkLine);
|
||||
}
|
||||
/* Get a joypad state */
|
||||
void InfoNES_PadState(DWORD *pdwPad1, DWORD *pdwPad2, DWORD *pdwSystem)
|
||||
|
||||
@@ -6,12 +6,36 @@
|
||||
#include <u_sleep.h>
|
||||
#include <u_sys.h>
|
||||
#include <u_thread.h>
|
||||
// #include <NES_Simulator/nes_main.h>
|
||||
#ifndef INFONES
|
||||
#include <NES_Simulator/nes_main.h>
|
||||
#else
|
||||
#include <InfoNES.h>
|
||||
#endif
|
||||
void delay_ms(int ms)
|
||||
{
|
||||
u_sleep_ms(ms);
|
||||
}
|
||||
#ifdef INFONES
|
||||
#define BGR565TORGB565(a) (((a) >> 11) | ((a) & (0x3f << 5)) | (a & 0x1f) << 11)
|
||||
void nes_lcd_color_fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *color)
|
||||
{
|
||||
uint16_t height, width;
|
||||
uint16_t i, j;
|
||||
|
||||
width = ex - sx + 1;
|
||||
height = ey - sy + 1;
|
||||
|
||||
lcd_windows_set(sx, sy, ex, ey);
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
lcd_data_16bit_write(BGR565TORGB565(color[i * width + j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void NES_LCD_DisplayLine(int y_axes, uint16_t *Disaplyline_buffer)
|
||||
{
|
||||
lcd_color_fill(0, y_axes, 256, y_axes, Disaplyline_buffer);
|
||||
@@ -58,11 +82,14 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
while (1)
|
||||
{
|
||||
// nes_main();
|
||||
#ifndef INFONES
|
||||
nes_main();
|
||||
#else
|
||||
if (InfoNES_Load(NULL) == 0)
|
||||
{
|
||||
FrameSkip = 2;
|
||||
InfoNES_Main();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user