Lynx: Handy now compiles + fixed esp-idf PROJECT_VER

This commit is contained in:
Alex Duchesne 2020-05-22 09:14:45 -04:00
parent e6ba071510
commit c1aa4ff15d
22 changed files with 104 additions and 64 deletions

View File

@ -4,6 +4,8 @@
#
PROJECT_NAME := gnuboy-go
PROJECT_VER := $(shell date "+%Y%m%d")-$(shell git rev-parse HEAD | cut -b 1-10)
EXTRA_COMPONENT_DIRS := ../components
CPPFLAGS += -DENABLE_NETPLAY

View File

@ -6,7 +6,5 @@
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#
COMPILEDATE:=\"$(shell date "+%Y%m%d")\"
GITREV:=\"$(shell git rev-parse HEAD | cut -b 1-10)\"
CFLAGS += -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"
CFLAGS += -O3 -DPROJECT_VER='"$(PROJECT_VER)"'

View File

@ -234,7 +234,8 @@ static bool advanced_settings_cb(odroid_dialog_choice_t *option, odroid_dialog_e
void app_main(void)
{
printf("gnuboy-go (%s-%s).\n", COMPILEDATE, GITREV);
printf("\n========================================\n\n");
printf("gnuboy-go (%s).\n", PROJECT_VER);
// Init all the console hardware
odroid_system_init(APP_ID, AUDIO_SAMPLE_RATE);

View File

@ -4,6 +4,8 @@
#
PROJECT_NAME := handy-go
PROJECT_VER := $(shell date "+%Y%m%d")-$(shell git rev-parse HEAD | cut -b 1-10)
EXTRA_COMPONENT_DIRS := ../components
# CPPFLAGS += -DENABLE_NETPLAY

View File

@ -53,7 +53,7 @@
#include "system.h"
#include "cart.h"
//#include "zlib.h"
#include "scrc32.h"
#include "rom/crc.h"
CCart::CCart(UBYTE *gamedata,ULONG gamesize)
{
@ -66,8 +66,7 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize)
mCartRAM=FALSE;
mHeaderLess=0;
mEEPROMType=0;
mCRC32=0;
mCRC32=crc32(mCRC32,gamedata,gamesize);
mCRC32=crc32_le(0,gamedata,gamesize);
// Open up the file
@ -121,7 +120,8 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize)
// Set the filetypes
CTYPE banktype0,banktype1;
CTYPE banktype0 = UNUSED;
CTYPE banktype1 = UNUSED;
switch(header.page_size_bank0) {
case 0x000:
@ -222,7 +222,7 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize)
memset(mCartBank1A, DEFAULT_CART_CONTENTS, bank1size);
if(bank0size==1) bank0size=0;// workaround ...
if(bank1size==1) bank1size=0;// workaround ...
memcpy(
mCartBank0,
gamedata+(headersize),
@ -462,7 +462,7 @@ void CCart::Poke0A(UBYTE data)
{
if(mWriteEnableBank0) {
ULONG address=(mShifter<<mShiftCount0)+(mCounter&mCountMask0);
mCartBank0A[address&mMaskBank0]=data;
mCartBank0A[address&mMaskBank0]=data;
}
if(!mStrobe) {
mCounter++;
@ -486,7 +486,7 @@ void CCart::Poke1A(UBYTE data)
{
if(mWriteEnableBank1) {
ULONG address=(mShifter<<mShiftCount1)+(mCounter&mCountMask1);
mCartBank1A[address&mMaskBank1]=data;
mCartBank1A[address&mMaskBank1]=data;
}
if(!mStrobe) {
mCounter++;
@ -510,7 +510,7 @@ UBYTE CCart::Peek0(void)
UBYTE CCart::Peek0A(void)
{
ULONG address=(mShifter<<mShiftCount0)+(mCounter&mCountMask0);
UBYTE data=mCartBank0A[address&mMaskBank0];
UBYTE data=mCartBank0A[address&mMaskBank0];
if(!mStrobe) {
mCounter++;
@ -536,7 +536,7 @@ UBYTE CCart::Peek1(void)
UBYTE CCart::Peek1A(void)
{
ULONG address=(mShifter<<mShiftCount1)+(mCounter&mCountMask1);
UBYTE data=mCartBank1A[address&mMaskBank1];
UBYTE data=mCartBank1A[address&mMaskBank1];
if(!mStrobe) {
mCounter++;

View File

@ -7,5 +7,8 @@
# please read the ESP-IDF documents if you need to do this.
#
CFLAGS += -O3 -DLSB_FIRST=1 -Wno-all -Wno-error
CXXFLAGS += -O3 -DLSB_FIRST=1 -Wno-all -Wno-error
COMPONENT_ADD_INCLUDEDIRS := .
COMPONENT_SRCDIRS := .
CFLAGS += -O3 -DLSB_FIRST=1 -Wall -Wno-comment -Wno-error=comment
CXXFLAGS += -O3 -DLSB_FIRST=1 -Wall -Wno-comment -Wno-error=comment

View File

@ -0,0 +1,5 @@
#undef INTSET
#undef PS
#include "system.h"
#include "lynxdef.h"

View File

@ -90,12 +90,12 @@ void CMikie::BlowOut(void)
for(loop=0;loop<16;loop++) mPalette[loop].Index=loop;
for(loop=0;loop<4096;loop++) mColourMap[loop]=0;
mikbuf.set_sample_rate(HANDY_AUDIO_SAMPLE_FREQ, 60);
mikbuf.clock_rate(HANDY_SYSTEM_FREQ / 4);
mikbuf.bass_freq(60);
miksynth.volume(0.50);
miksynth.treble_eq(0);
// mikbuf.set_sample_rate(HANDY_AUDIO_SAMPLE_FREQ, 60);
// mikbuf.clock_rate(HANDY_SYSTEM_FREQ / 4);
// mikbuf.bass_freq(60);
// miksynth.volume(0.50);
// miksynth.treble_eq(0);
Reset();
}
@ -369,13 +369,13 @@ bool CMikie::ContextSave(LSS_FILE *fp)
if(!lss_write(&mAudioInputComparator,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mTimerStatusFlags,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mTimerInterruptMask,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(mPalette,sizeof(TPALETTE),16,fp)) return 0;
if(!lss_write(&mIODAT,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mIODAT_REST_SIGNAL,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mIODIR,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mDISPCTL_DMAEnable,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mDISPCTL_Flip,sizeof(ULONG),1,fp)) return 0;
if(!lss_write(&mDISPCTL_FourColour,sizeof(ULONG),1,fp)) return 0;
@ -806,8 +806,8 @@ void CMikie::ComLynxRxData(int data)
if(!mUART_Rx_waiting) mUART_RX_COUNTDOWN=UART_RX_TIME_PERIOD;
// Receive the byte
mUART_Rx_input_queue[mUART_Rx_input_ptr]=data;
mUART_Rx_input_ptr=(++mUART_Rx_input_ptr)%UART_MAX_RX_QUEUE;
mUART_Rx_input_queue[mUART_Rx_input_ptr++]=data;
mUART_Rx_input_ptr %= UART_MAX_RX_QUEUE;
mUART_Rx_waiting++;
TRACE_MIKIE2("ComLynxRxData() - input ptr=%02d waiting=%02d",mUART_Rx_input_ptr,mUART_Rx_waiting);
} else {
@ -825,7 +825,8 @@ void CMikie::ComLynxTxLoopback(int data)
if(!mUART_Rx_waiting) mUART_RX_COUNTDOWN=UART_RX_TIME_PERIOD;
// Receive the byte - INSERT into front of queue
mUART_Rx_output_ptr=(--mUART_Rx_output_ptr)%UART_MAX_RX_QUEUE;
mUART_Rx_output_ptr--;
mUART_Rx_output_ptr %= UART_MAX_RX_QUEUE;
mUART_Rx_input_queue[mUART_Rx_output_ptr]=data;
mUART_Rx_waiting++;
TRACE_MIKIE2("ComLynxTxLoopback() - input ptr=%02d waiting=%02d",mUART_Rx_input_ptr,mUART_Rx_waiting);
@ -872,14 +873,14 @@ void CMikie::DisplaySetAttributes(ULONG Rotate,ULONG Format,ULONG Pitch,UBYTE* (
break;
case MIKIE_PIXEL_FORMAT_16BPP_555:
for(Spot.Index=0;Spot.Index<4096;Spot.Index++) {
mColourMap[Spot.Index]=((Spot.Colours.Red<<11)&0x7800) | (Spot.Colours.Red<<7)&0x0400;
mColourMap[Spot.Index]=((Spot.Colours.Red<<11)&0x7800) | ((Spot.Colours.Red<<7)&0x0400);
mColourMap[Spot.Index]|=((Spot.Colours.Green<<6)&0x03c0) | ((Spot.Colours.Green<<2)&0x0020);
mColourMap[Spot.Index]|=((Spot.Colours.Blue<<1)&0x001e) | ((Spot.Colours.Blue>>3)&0x0001);
}
break;
case MIKIE_PIXEL_FORMAT_16BPP_565:
for(Spot.Index=0;Spot.Index<4096;Spot.Index++) {
mColourMap[Spot.Index]=((Spot.Colours.Red<<12)&0xf000) | (Spot.Colours.Red<<8)&0x0800;
mColourMap[Spot.Index]=((Spot.Colours.Red<<12)&0xf000) | ((Spot.Colours.Red<<8)&0x0800);
mColourMap[Spot.Index]|=((Spot.Colours.Green<<7)&0x0780) | ((Spot.Colours.Green<<3)&0x0060);
mColourMap[Spot.Index]|=((Spot.Colours.Blue<<1)&0x001e) | ((Spot.Colours.Blue>>3)&0x0001);
}
@ -1263,9 +1264,9 @@ ULONG CMikie::DisplayEndOfFrame(void)
if(gCPUWakeupTime) {
gCPUWakeupTime = 0;
ClearCPUSleep();
ClearCPUSleep();
}
// Set the timer status flag
if(mTimerInterruptMask&0x04) {
TRACE_MIKIE0("Update() - TIMER2 IRQ Triggered (Frame Timer)");
@ -1311,8 +1312,8 @@ ULONG CMikie::DisplayEndOfFrame(void)
break;
}
mikbuf.end_frame((gSystemCycleCount - gAudioLastUpdateCycle) / 4);
gAudioBufferPointer = mikbuf.read_samples((blip_sample_t*) gAudioBuffer, HANDY_AUDIO_BUFFER_SIZE / 2) * 2;
// mikbuf.end_frame((gSystemCycleCount - gAudioLastUpdateCycle) / 4);
// gAudioBufferPointer = mikbuf.read_samples((blip_sample_t*) gAudioBuffer, HANDY_AUDIO_BUFFER_SIZE / 2) * 2;
return 0;
}
@ -2596,9 +2597,9 @@ UBYTE CMikie::Peek(ULONG addr)
inline void CMikie::Update(void)
{
SLONG divide;
SLONG decval;
ULONG tmp;
SLONG divide = 0;
SLONG decval = 0;
ULONG tmp = 0;
ULONG mikie_work_done=0;
//
@ -2880,8 +2881,8 @@ inline void CMikie::Update(void)
if(!mUART_RX_COUNTDOWN) {
// Fetch a byte from the input queue
if(mUART_Rx_waiting>0) {
mUART_RX_DATA=mUART_Rx_input_queue[mUART_Rx_output_ptr];
mUART_Rx_output_ptr=(++mUART_Rx_output_ptr)%UART_MAX_RX_QUEUE;
mUART_RX_DATA = mUART_Rx_input_queue[mUART_Rx_output_ptr++];
mUART_Rx_output_ptr %= UART_MAX_RX_QUEUE;
mUART_Rx_waiting--;
TRACE_MIKIE2("Update() - RX Byte output ptr=%02d waiting=%02d",mUART_Rx_output_ptr,mUART_Rx_waiting);
} else {
@ -3727,12 +3728,12 @@ inline void CMikie::UpdateSound(void)
static int last_rsample = 0;
if(cur_lsample != last_lsample) {
miksynth.offset_inline((gSystemCycleCount - gAudioLastUpdateCycle) / 4, cur_lsample - last_lsample, mikbuf.left());
// miksynth.offset_inline((gSystemCycleCount - gAudioLastUpdateCycle) / 4, cur_lsample - last_lsample, mikbuf.left());
last_lsample = cur_lsample;
}
if(cur_rsample != last_rsample) {
miksynth.offset_inline((gSystemCycleCount - gAudioLastUpdateCycle) / 4, cur_rsample - last_rsample, mikbuf.right());
// miksynth.offset_inline((gSystemCycleCount - gAudioLastUpdateCycle) / 4, cur_rsample - last_rsample, mikbuf.right());
last_rsample = cur_rsample;
}
}

View File

@ -180,9 +180,9 @@ enum
MIKIE_PIXEL_FORMAT_32BPP,
};
#include <blip/Stereo_Buffer.h>
// #include <blip/Stereo_Buffer.h>
typedef Blip_Synth<blip_good_quality, 256 * 4> Synth;
// typedef Blip_Synth<blip_good_quality, 256 * 4> Synth;
class CMikie : public CLynxBase
{
@ -190,8 +190,8 @@ class CMikie : public CLynxBase
CMikie(CSystem& parent);
~CMikie();
Synth miksynth;
Stereo_Buffer mikbuf;
// Synth miksynth;
// Stereo_Buffer mikbuf;
bool ContextSave(LSS_FILE *fp);
bool ContextLoad(LSS_FILE *fp);

View File

@ -46,8 +46,8 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#pragma inline_depth (255)
#pragma inline_recursion (on)
// #pragma inline_depth (255)
// #pragma inline_recursion (on)
#ifdef _LYNXDBG

View File

@ -6,7 +6,6 @@
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#
COMPILEDATE:=\"$(shell date "+%Y%m%d")\"
GITREV:=\"$(shell git rev-parse HEAD | cut -b 1-10)\"
CFLAGS += -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"
CFLAGS += -DPROJECT_VER='"$(PROJECT_VER)"' -Wall -Wno-comment -Wno-error=comment
CXXFLAGS += -DPROJECT_VER='"$(PROJECT_VER)"' -Wall -Wno-comment -Wno-error=comment

View File

@ -1,15 +1,19 @@
extern "C" {
#include <freertos/FreeRTOS.h>
#include <odroid_system.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}
#include "handy.h"
#include <handy.h>
#define APP_ID 50
#define AUDIO_SAMPLE_RATE 22050
static CSystem *lynx = NULL;
// static bool netplay = false;
// --- MAIN
@ -22,13 +26,21 @@ static bool save_state(char *pathName)
static bool load_state(char *pathName)
{
lynx->Reset();
return true;
}
void app_main(void)
static UBYTE* lynx_display_callback(ULONG objref)
{
printf("Handy-go (%s-%s).\n", COMPILEDATE, GITREV);
return 0;
}
extern "C" void app_main(void)
{
printf("\n========================================\n\n");
printf("Handy-go (%s).\n", PROJECT_VER);
odroid_system_init(APP_ID, AUDIO_SAMPLE_RATE);
odroid_system_emu_init(&load_state, &save_state, NULL);
@ -36,6 +48,14 @@ void app_main(void)
char *romFile = odroid_system_get_path(ODROID_PATH_ROM_FILE);
// Init emulator
lynx = new CSystem(romFile, "bios", true);
lynx->SetButtonData(0);
lynx->DisplaySetAttributes(
MIKIE_NO_ROTATE,
MIKIE_PIXEL_FORMAT_16BPP_565,
SCREEN_WIDTH * 2,
lynx_display_callback,
0);
if (odroid_system_get_start_action() == ODROID_START_ACTION_RESUME)
{
@ -43,6 +63,10 @@ void app_main(void)
}
// Start emulation
while (1)
{
lynx->Update();
}
printf("Handy died.\n");
abort();

View File

@ -4,6 +4,8 @@
#
PROJECT_NAME := huexpress-go
PROJECT_VER := $(shell date "+%Y%m%d")-$(shell git rev-parse HEAD | cut -b 1-10)
EXTRA_COMPONENT_DIRS := ../components
include $(IDF_PATH)/make/project.mk

View File

@ -6,8 +6,6 @@
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#
COMPILEDATE:=\"$(shell date "+%Y%m%d")\"
GITREV:=\"$(shell git rev-parse HEAD | cut -b 1-10)\"
CFLAGS += -Ofast -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"
CPPFLAGS += -Ofast -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"
CFLAGS += -Ofast -DPROJECT_VER='"$(PROJECT_VER)"'
CPPFLAGS += -Ofast -DPROJECT_VER='"$(PROJECT_VER)"'

View File

@ -34,7 +34,8 @@ static bool load_state(char *pathName)
void app_main(void)
{
printf("HuExpress-go (%s-%s).\n", COMPILEDATE, GITREV);
printf("\n========================================\n\n");
printf("HuExpress-go (%s).\n", PROJECT_VER);
odroid_system_init(APP_ID, AUDIO_SAMPLE_RATE);
odroid_system_emu_init(&load_state, &save_state, NULL);

View File

@ -164,7 +164,7 @@ static bool advanced_settings_cb(odroid_dialog_choice_t *option, odroid_dialog_e
{1, "Region", "Auto", 1, &region_update_cb},
{2, "Overscan", "Auto", 1, &overscan_update_cb},
{3, "Sprite limit", "On ", 1, &sprite_limit_cb},
{4, "Left column", "Normal/Black/Crop ", 1, &leftcol_update_cb},
// {4, "Left column", "Normal/Black/Crop ", 1, &leftcol_update_cb},
// {4, "", "", 1, NULL},
//{0, "Reset all", "", 1, NULL},
ODROID_DIALOG_CHOICE_LAST

View File

@ -4,6 +4,8 @@
#
PROJECT_NAME := retro-go
PROJECT_VER := $(shell date "+%Y%m%d")-$(shell git rev-parse HEAD | cut -b 1-10)
EXTRA_COMPONENT_DIRS := ../components
include $(IDF_PATH)/make/project.mk

View File

@ -8,4 +8,4 @@
#
COMPILEDATE:=\"$(shell date "+%Y-%m-%d")\"
GITREV:=\"$(shell git rev-parse HEAD | cut -b 1-10)\"
CFLAGS += -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"
CFLAGS += -DPROJECT_VER='"$(PROJECT_VER)"' -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"

View File

@ -279,7 +279,8 @@ void retro_loop()
void app_main(void)
{
printf("Retro-Go (%s-%s).\n", COMPILEDATE, GITREV);
printf("\n========================================\n\n");
printf("Retro-Go (%s).\n", PROJECT_VER);
odroid_system_init(0, 32000);
odroid_display_clear(0);

View File

@ -4,6 +4,8 @@
#
PROJECT_NAME := smsplusgx-go
PROJECT_VER := $(shell date "+%Y%m%d")-$(shell git rev-parse HEAD | cut -b 1-10)
EXTRA_COMPONENT_DIRS := ../components
include $(IDF_PATH)/make/project.mk

View File

@ -6,7 +6,5 @@
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#
COMPILEDATE:=\"$(shell date "+%Y%m%d")\"
GITREV:=\"$(shell git rev-parse HEAD | cut -b 1-10)\"
CFLAGS += -DCOMPILEDATE="$(COMPILEDATE)" -DGITREV="$(GITREV)"
CFLAGS += -DPROJECT_VER='"$(PROJECT_VER)"'

View File

@ -115,7 +115,8 @@ void system_manage_sram(uint8 *sram, int slot, int mode)
void app_main(void)
{
printf("SMSPlusGX-go (%s-%s).\n", COMPILEDATE, GITREV);
printf("\n========================================\n\n");
printf("SMSPlusGX-go (%s).\n", PROJECT_VER);
// Init all the console hardware
odroid_system_init(APP_ID, AUDIO_SAMPLE_RATE);