├── .clang-format ├── .gitignore ├── LICENSE ├── README.md ├── custom.csv ├── format_src.sh ├── include └── README ├── lib └── README ├── platformio.ini ├── src ├── main.cpp └── rachel │ ├── apps │ ├── app_ble_gamepad │ │ ├── app_ble_gamepad.cpp │ │ ├── app_ble_gamepad.h │ │ └── assets │ │ │ ├── README │ │ │ └── icon_app_ble_gamepad.hpp │ ├── app_genshin │ │ ├── app_genshin.cpp │ │ ├── app_genshin.h │ │ └── assets │ │ │ ├── README │ │ │ └── icon_app_genshin.hpp │ ├── app_music │ │ ├── app_music.cpp │ │ ├── app_music.h │ │ └── assets │ │ │ ├── README │ │ │ ├── buzz_music │ │ │ ├── buzz_music_note_converter.py │ │ │ ├── happybirthday.json │ │ │ ├── harrypotter.json │ │ │ ├── nokia.json │ │ │ ├── starwars.json │ │ │ └── supermariobros.json │ │ │ └── icon_app_music.hpp │ ├── app_nofrendo │ │ ├── app_nofrendo.cpp │ │ ├── app_nofrendo.h │ │ ├── assets │ │ │ ├── README │ │ │ └── icon_app_nofrendo.hpp │ │ ├── nofrendo-esp32 │ │ │ ├── osd.c │ │ │ ├── port.cpp │ │ │ ├── port.h │ │ │ └── video_audio.c │ │ └── nofrendo │ │ │ ├── AUTHORS │ │ │ ├── bitmap.c │ │ │ ├── bitmap.h │ │ │ ├── config.c │ │ │ ├── cpu │ │ │ ├── dis6502.c │ │ │ ├── dis6502.h │ │ │ ├── nes6502.c │ │ │ └── nes6502.h │ │ │ ├── event.c │ │ │ ├── event.h │ │ │ ├── gui.c │ │ │ ├── gui.h │ │ │ ├── gui_elem.c │ │ │ ├── gui_elem.h │ │ │ ├── intro.c │ │ │ ├── intro.h │ │ │ ├── libsnss │ │ │ ├── libsnss.c │ │ │ └── libsnss.h │ │ │ ├── log.c │ │ │ ├── log.h │ │ │ ├── mappers │ │ │ ├── map000.c │ │ │ ├── map001.c │ │ │ ├── map002.c │ │ │ ├── map003.c │ │ │ ├── map004.c │ │ │ ├── map005.c │ │ │ ├── map007.c │ │ │ ├── map008.c │ │ │ ├── map009.c │ │ │ ├── map010.c │ │ │ ├── map011.c │ │ │ ├── map015.c │ │ │ ├── map016.c │ │ │ ├── map018.c │ │ │ ├── map019.c │ │ │ ├── map024.c │ │ │ ├── map032.c │ │ │ ├── map033.c │ │ │ ├── map034.c │ │ │ ├── map040.c │ │ │ ├── map041.c │ │ │ ├── map042.c │ │ │ ├── map046.c │ │ │ ├── map050.c │ │ │ ├── map064.c │ │ │ ├── map065.c │ │ │ ├── map066.c │ │ │ ├── map070.c │ │ │ ├── map073.c │ │ │ ├── map075.c │ │ │ ├── map078.c │ │ │ ├── map079.c │ │ │ ├── map085.c │ │ │ ├── map087.c │ │ │ ├── map093.c │ │ │ ├── map094.c │ │ │ ├── map099.c │ │ │ ├── map160.c │ │ │ ├── map229.c │ │ │ ├── map231.c │ │ │ └── mapvrc.c │ │ │ ├── memguard.c │ │ │ ├── memguard.h │ │ │ ├── nes │ │ │ ├── mmclist.c │ │ │ ├── mmclist.h │ │ │ ├── nes.c │ │ │ ├── nes.h │ │ │ ├── nes_mmc.c │ │ │ ├── nes_mmc.h │ │ │ ├── nes_pal.c │ │ │ ├── nes_pal.h │ │ │ ├── nes_ppu.c │ │ │ ├── nes_ppu.h │ │ │ ├── nes_rom.c │ │ │ ├── nes_rom.h │ │ │ ├── nesinput.c │ │ │ ├── nesinput.h │ │ │ ├── nesstate.c │ │ │ └── nesstate.h │ │ │ ├── nofconfig.h │ │ │ ├── nofrendo.c │ │ │ ├── nofrendo.h │ │ │ ├── noftypes.h │ │ │ ├── osd.h │ │ │ ├── pcx.c │ │ │ ├── pcx.h │ │ │ ├── sndhrdw │ │ │ ├── fds_snd.c │ │ │ ├── fds_snd.h │ │ │ ├── mmc5_snd.c │ │ │ ├── mmc5_snd.h │ │ │ ├── nes_apu.c │ │ │ ├── nes_apu.h │ │ │ ├── vrcvisnd.c │ │ │ └── vrcvisnd.h │ │ │ ├── version.h │ │ │ ├── vid_drv.c │ │ │ └── vid_drv.h │ ├── app_raylib_games │ │ ├── app_raylib_games.cpp │ │ ├── app_raylib_games.h │ │ ├── assets │ │ │ ├── README │ │ │ └── icon_app_raylib_games.hpp │ │ ├── games │ │ │ ├── arkanoid.cpp │ │ │ ├── games.h │ │ │ ├── snake.cpp │ │ │ └── tetris.cpp │ │ └── raylib │ │ │ ├── raylib.cpp │ │ │ └── raylib.h │ ├── app_screencast │ │ ├── app_screencast.cpp │ │ ├── app_screencast.h │ │ ├── assets │ │ │ ├── README │ │ │ └── icon_app_screen_cast.hpp │ │ └── screen_shot_receiver │ │ │ ├── TCPReceiver.h │ │ │ ├── tjpgdClass.cpp │ │ │ └── tjpgdClass.h │ ├── app_settings │ │ ├── app_settings.cpp │ │ ├── app_settings.h │ │ ├── assets │ │ │ ├── README │ │ │ ├── icon_app_settings.hpp │ │ │ └── page_about_png.hpp │ │ └── pages │ │ │ ├── page_about.cpp │ │ │ ├── page_display.cpp │ │ │ ├── page_index.cpp │ │ │ ├── page_power.cpp │ │ │ ├── page_sound.cpp │ │ │ └── page_time.cpp │ ├── app_template │ │ ├── app_template.cpp │ │ ├── app_template.h │ │ └── assets │ │ │ └── README │ ├── apps.h │ ├── assets │ │ ├── fonts │ │ │ ├── fonts.h │ │ │ ├── zpix_24.vlw │ │ │ └── zpix_cn_24.vlw │ │ ├── icons │ │ │ ├── icon_app_default.hpp │ │ │ └── icons.h │ │ └── theme │ │ │ └── theme.h │ ├── launcher │ │ ├── assets │ │ │ └── launcher_bottom_panel.hpp │ │ ├── launcher.cpp │ │ ├── launcher.h │ │ └── view │ │ │ ├── app_anim.cpp │ │ │ ├── menu.cpp │ │ │ └── menu_render_callback.hpp │ ├── tools │ │ └── app_generator.py │ └── utils │ │ ├── smooth_menu │ │ ├── camera │ │ │ ├── camera.cpp │ │ │ └── camera.h │ │ ├── lv_anim │ │ │ ├── lv_anim.cpp │ │ │ └── lv_anim.h │ │ ├── menu │ │ │ ├── menu.cpp │ │ │ └── menu.h │ │ ├── selector │ │ │ ├── selector.cpp │ │ │ └── selector.h │ │ └── simple_menu │ │ │ ├── simple_menu.cpp │ │ │ └── simple_menu.h │ │ └── system │ │ ├── audio │ │ ├── audio.h │ │ └── buzz_music_player │ │ │ ├── buzz_music_player.cpp │ │ │ └── buzz_music_player.h │ │ ├── inputs │ │ ├── button │ │ │ ├── button.cpp │ │ │ └── button.h │ │ └── inputs.h │ │ └── ui │ │ ├── common │ │ └── data_structs.hpp │ │ ├── progress_window │ │ ├── progress_window.cpp │ │ └── progress_window.h │ │ ├── select_menu │ │ ├── components │ │ │ ├── rcb_align_center.cpp │ │ │ ├── rcb_align_left.cpp │ │ │ ├── rcb_align_right.cpp │ │ │ └── render_callbacks.h │ │ ├── select_menu.cpp │ │ └── select_menu.h │ │ └── ui.h │ ├── hal │ ├── hal.cpp │ ├── hal.h │ ├── hal_rachel │ │ ├── components │ │ │ ├── hal_display.cpp │ │ │ ├── hal_fs.cpp │ │ │ ├── hal_gamepad.cpp │ │ │ ├── hal_i2c.cpp │ │ │ ├── hal_imu.cpp │ │ │ ├── hal_power.cpp │ │ │ ├── hal_rtc.cpp │ │ │ ├── hal_sdcard.cpp │ │ │ └── hal_speaker.cpp │ │ ├── hal_config.h │ │ ├── hal_rachel.h │ │ └── utils │ │ │ └── m5unified │ │ │ ├── I2C_Class.cpp │ │ │ ├── I2C_Class.hpp │ │ │ ├── IMU_Class.cpp │ │ │ ├── IMU_Class.hpp │ │ │ ├── RTC8563_Class.cpp │ │ │ ├── RTC8563_Class.hpp │ │ │ ├── Speaker_Class.cpp │ │ │ ├── Speaker_Class.hpp │ │ │ └── imu │ │ │ ├── BMI270_Class.cpp │ │ │ ├── BMI270_Class.hpp │ │ │ ├── BMI270_config.inl │ │ │ ├── IMU_Base.cpp │ │ │ └── IMU_Base.hpp │ ├── hal_simulator │ │ └── hal_simulator.hpp │ └── lgfx_fx │ │ ├── lgfx_fx.cpp │ │ └── lgfx_fx.h │ ├── rachel.cpp │ └── rachel.h └── test └── README /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # We'll use defaults from the LLVM style, but with 4 columns indentation. 3 | BasedOnStyle: LLVM 4 | 5 | --- 6 | Language: Cpp 7 | # Force pointers to the type for C++. 8 | ColumnLimit: 128 9 | IndentWidth: 4 10 | NamespaceIndentation: All 11 | AccessModifierOffset: -4 12 | DerivePointerAlignment: false 13 | PointerAlignment: Left 14 | BreakBeforeBraces: Allman 15 | BinPackArguments: false 16 | BinPackParameters: false 17 | AlwaysBreakTemplateDeclarations: Yes 18 | SortIncludes: false 19 | # AllowShortBlocksOnASingleLine: Always 20 | # AllowShortCaseLabelsOnASingleLine: false 21 | 22 | --- 23 | Language: JavaScript 24 | # Use 100 columns for JS. 25 | ColumnLimit: 100 26 | --- 27 | Language: Proto 28 | # Don't format .proto files. 29 | DisableFormat: true 30 | --- 31 | Language: CSharp 32 | # Use 100 columns for C#. 33 | ColumnLimit: 100 34 | 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Forairaaaaa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /custom.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 3M, 5 | # app1, app, ota_1, 0x340000,0x330000, 6 | gamerom, 0x40, 0x01, , 2M 7 | spiffs, data, spiffs, , 0x3e800, 8 | coredump, data, coredump,0x7F0000,0x10000, -------------------------------------------------------------------------------- /format_src.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | CLANG_FORMAT=clang-format 3 | TARGET_FILES=$(find ./src -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \)) 4 | 5 | echo "start formatting.." 6 | for file in $TARGET_FILES; do 7 | if [ -f "$file" ]; then 8 | echo "fxxxxtting $file" 9 | $CLANG_FORMAT -i -style=file "$file" 10 | fi 11 | done 12 | echo "done" 13 | -------------------------------------------------------------------------------- /include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:rachel-sdk] 12 | platform = espressif32@6.4.0 13 | board = esp32-s3-devkitc-1 14 | framework = arduino 15 | 16 | board_build.f_cpu = 240000000L 17 | 18 | build_flags = 19 | -DCORE_DEBUG_LEVEL=3 20 | -I./src/rachel/apps/app_nofrendo/nofrendo 21 | -I./src/rachel/apps/app_nofrendo/nofrendo/cpu 22 | -I./src/rachel/apps/app_nofrendo/nofrendo/libsnss 23 | -I./src/rachel/apps/app_nofrendo/nofrendo/mappers 24 | -I./src/rachel/apps/app_nofrendo/nofrendo/nes 25 | -I./src/rachel/apps/app_nofrendo/nofrendo/sndhrdw 26 | 27 | board_build.partitions = custom.csv 28 | board_build.filesystem = littlefs 29 | 30 | lib_deps = 31 | forairaaaaa/Mooncake @ 1.0.4 32 | lovyan03/LovyanGFX @ 1.1.12 33 | bblanchon/ArduinoJson @ 6.21.3 34 | lemmingdev/ESP32-BLE-Gamepad @ 0.5.2 35 | 36 | monitor_filters = esp32_exception_decoder 37 | monitor_speed = 115200 38 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file main.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "rachel/rachel.h" 12 | 13 | void setup() { RACHEL::Setup(); } 14 | 15 | void loop() { RACHEL::Loop(); } 16 | -------------------------------------------------------------------------------- /src/rachel/apps/app_ble_gamepad/app_ble_gamepad.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_ble_gamepad.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-19 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_ble_gamepad.hpp" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Ble_controller 18 | * 19 | */ 20 | class AppBle_gamepad : public APP_BASE 21 | { 22 | public: 23 | void onCreate() override; 24 | void onResume() override; 25 | void onRunning() override; 26 | void onDestroy() override; 27 | }; 28 | 29 | class AppBle_gamepad_Packer : public APP_PACKER_BASE 30 | { 31 | std::string getAppName() override { return "Ble Gamepad"; } 32 | void* getAppIcon() override { return (void*)image_data_icon_app_ble_gamepad; } 33 | void* newApp() override { return new AppBle_gamepad; } 34 | void deleteApp(void* app) override { delete (AppBle_gamepad*)app; } 35 | }; 36 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_ble_gamepad/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_genshin/app_genshin.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_genshin.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_genshin.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | #include "../utils/system/ui/ui.h" 16 | 17 | using namespace MOONCAKE::APPS; 18 | 19 | void AppGenshin::onCreate() { spdlog::info("{} onCreate", getAppName()); } 20 | 21 | void AppGenshin::onResume() { spdlog::info("{} onResume", getAppName()); } 22 | 23 | using namespace SYSTEM::UI; 24 | 25 | void AppGenshin::onRunning() 26 | { 27 | HAL::LoadTextFont24(); 28 | 29 | // // Loading 30 | // std::vector title_list = {"传送松山湖..", "打捞..", "CPU热拔插.."}; 31 | // for (auto& title : title_list) 32 | // { 33 | // for (int i = 10; i <= 110; i += 20) 34 | // { 35 | // ProgressWindow(title, i); 36 | // HAL::CanvasUpdate(); 37 | // HAL::Delay(100); 38 | // } 39 | // } 40 | 41 | // Launch 42 | HAL::GetCanvas()->fillScreen(THEME_COLOR_LIGHT); 43 | HAL::CanvasUpdate(); 44 | HAL::Delay(2000); 45 | 46 | HAL::GetCanvas()->setTextSize(3); 47 | HAL::GetCanvas()->drawCenterString("原神", 120, 60); 48 | HAL::CanvasUpdate(); 49 | HAL::Delay(2000); 50 | 51 | HAL::GetCanvas()->setTextSize(1); 52 | HAL::GetCanvas()->fillScreen(THEME_COLOR_LIGHT); 53 | HAL::GetCanvas()->setCursor(32, HAL::GetCanvas()->height() / 3); 54 | std::vector item_list = {"火", "水", "风", "雷", "草", "冰"}; 55 | for (auto& i : item_list) 56 | { 57 | HAL::GetCanvas()->print(i.c_str()); 58 | HAL::CanvasUpdate(); 59 | HAL::Delay(400); 60 | } 61 | 62 | int cursor_x = HAL::GetCanvas()->getCursorX(); 63 | int cursor_y = HAL::GetCanvas()->getCursorY(); 64 | 65 | HAL::GetCanvas()->print("岩"); 66 | HAL::GetCanvas()->fillRect(cursor_x + 12, cursor_y, 24, 24, THEME_COLOR_LIGHT); 67 | HAL::CanvasUpdate(); 68 | HAL::Delay(2000); 69 | 70 | HAL::GetCanvas()->setCursor(cursor_x, cursor_y); 71 | HAL::GetCanvas()->print("岩"); 72 | HAL::CanvasUpdate(); 73 | HAL::Delay(1000); 74 | 75 | HAL::PopFatalError("你在期待什么? O.o"); 76 | 77 | destroyApp(); 78 | } 79 | 80 | void AppGenshin::onDestroy() { spdlog::info("{} onDestroy", getAppName()); } 81 | -------------------------------------------------------------------------------- /src/rachel/apps/app_genshin/app_genshin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_genshin.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_genshin.hpp" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Genshin 18 | * 19 | */ 20 | class AppGenshin : public APP_BASE 21 | { 22 | public: 23 | void onCreate() override; 24 | void onResume() override; 25 | void onRunning() override; 26 | void onDestroy() override; 27 | }; 28 | 29 | class AppGenshin_Packer : public APP_PACKER_BASE 30 | { 31 | std::string getAppName() override { return "Genshin"; } 32 | void* getAppIcon() override { return (void*)image_data_icon_app_genshin; } 33 | void* newApp() override { return new AppGenshin; } 34 | void deleteApp(void* app) override { delete (AppGenshin*)app; } 35 | }; 36 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_genshin/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/app_music.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_music.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_music.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | #include "../utils/system/ui/ui.h" 16 | #include "../utils/system/audio/audio.h" 17 | #ifdef ESP_PLATFORM 18 | #include 19 | #include 20 | #include 21 | #endif 22 | 23 | using namespace MOONCAKE::APPS; 24 | using namespace SYSTEM::UI; 25 | using namespace SYSTEM::AUDIO; 26 | 27 | void AppMusic::onCreate() { spdlog::info("{} onCreate", getAppName()); } 28 | 29 | void AppMusic::onResume() { spdlog::info("{} onResume", getAppName()); } 30 | 31 | #ifdef ESP_PLATFORM 32 | static const String _music_path = "/buzz_music"; 33 | 34 | void AppMusic::onRunning() 35 | { 36 | if (!HAL::CheckSdCard()) 37 | HAL::PopFatalError("没SD卡啊朋友"); 38 | spdlog::info("try loading music from SD card in {}", _music_path.c_str()); 39 | 40 | // Check path 41 | if (!SD.exists(_music_path)) 42 | { 43 | std::string msg = "音乐路径不存在\n ("; 44 | msg += _music_path.c_str(); 45 | msg += ")"; 46 | HAL::PopFatalError(msg); 47 | } 48 | 49 | // List music dir 50 | auto music_directory = SD.open(_music_path); 51 | std::vector music_list = {"[MUSIC]"}; 52 | while (1) 53 | { 54 | File entry = music_directory.openNextFile(); 55 | 56 | if (!entry) 57 | break; 58 | 59 | if (!entry.isDirectory()) 60 | { 61 | // Filter 62 | if (std::strstr(entry.name(), ".json") != NULL) 63 | { 64 | music_list.push_back(entry.name()); 65 | spdlog::info("get file: {} size: {}", entry.name(), entry.size()); 66 | } 67 | } 68 | 69 | entry.close(); 70 | } 71 | if (music_list.size() == 1) 72 | HAL::PopFatalError("没音乐啊朋友"); 73 | music_list.push_back("Quit"); 74 | 75 | // Create select menu 76 | SelectMenu menu; 77 | while (1) 78 | { 79 | auto selected_item = menu.waitResult(music_list); 80 | 81 | if (selected_item == music_list.size() - 1) 82 | break; 83 | 84 | // ~ 85 | HAL::GetCanvas()->fillSmoothRoundRect((240 - 180) / 2, (240 - 120) / 2, 180, 120, 20, THEME_COLOR_LIGHT); 86 | HAL::GetCanvas()->setTextColor(THEME_COLOR_DARK, THEME_COLOR_LIGHT); 87 | HAL::GetCanvas()->drawCenterString("Playing..", 120, 120 - 12); 88 | HAL::CanvasUpdate(); 89 | 90 | // Play 91 | String music_path = _music_path; 92 | music_path += "/"; 93 | music_path += music_list[selected_item].c_str(); 94 | BuzzMusicPlayer::playFromSdCard(music_path.c_str()); 95 | } 96 | 97 | destroyApp(); 98 | } 99 | #else 100 | 101 | void AppMusic::onRunning() { HAL::PopFatalError("懒得抽象了"); } 102 | 103 | #endif 104 | 105 | void AppMusic::onDestroy() { spdlog::info("{} onDestroy", getAppName()); } 106 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/app_music.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_music.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_music.hpp" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Music 18 | * 19 | */ 20 | class AppMusic : public APP_BASE 21 | { 22 | public: 23 | void onCreate() override; 24 | void onResume() override; 25 | void onRunning() override; 26 | void onDestroy() override; 27 | }; 28 | 29 | class AppMusic_Packer : public APP_PACKER_BASE 30 | { 31 | std::string getAppName() override { return "Music"; } 32 | void* getAppIcon() override { return (void*)image_data_icon_app_music; } 33 | void* newApp() override { return new AppMusic; } 34 | void deleteApp(void* app) override { delete (AppMusic*)app; } 35 | }; 36 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/buzz_music/buzz_music_note_converter.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os as os 3 | 4 | 5 | noteTable = { 6 | "NOTE_B0" : 31, 7 | "NOTE_C1" : 33, 8 | "NOTE_CS1" : 35, 9 | "NOTE_D1" : 37, 10 | "NOTE_DS1" : 39, 11 | "NOTE_E1" : 41, 12 | "NOTE_F1" : 44, 13 | "NOTE_FS1" : 46, 14 | "NOTE_G1" : 49, 15 | "NOTE_GS1" : 52, 16 | "NOTE_A1" : 55, 17 | "NOTE_AS1" : 58, 18 | "NOTE_B1" : 62, 19 | "NOTE_C2" : 65, 20 | "NOTE_CS2" : 69, 21 | "NOTE_D2" : 73, 22 | "NOTE_DS2" : 78, 23 | "NOTE_E2" : 82, 24 | "NOTE_F2" : 87, 25 | "NOTE_FS2" : 93, 26 | "NOTE_G2" : 98, 27 | "NOTE_GS2" : 104, 28 | "NOTE_A2" : 110, 29 | "NOTE_AS2" : 117, 30 | "NOTE_B2" : 123, 31 | "NOTE_C3" : 131, 32 | "NOTE_CS3" : 139, 33 | "NOTE_D3" : 147, 34 | "NOTE_DS3" : 156, 35 | "NOTE_E3" : 165, 36 | "NOTE_F3" : 175, 37 | "NOTE_FS3" : 185, 38 | "NOTE_G3" : 196, 39 | "NOTE_GS3" : 208, 40 | "NOTE_A3" : 220, 41 | "NOTE_AS3" : 233, 42 | "NOTE_B3" : 247, 43 | "NOTE_C4" : 262, 44 | "NOTE_CS4" : 277, 45 | "NOTE_D4" : 294, 46 | "NOTE_DS4" : 311, 47 | "NOTE_E4" : 330, 48 | "NOTE_F4" : 349, 49 | "NOTE_FS4" : 370, 50 | "NOTE_G4" : 392, 51 | "NOTE_GS4" : 415, 52 | "NOTE_A4" : 440, 53 | "NOTE_AS4" : 466, 54 | "NOTE_B4" : 494, 55 | "NOTE_C5" : 523, 56 | "NOTE_CS5" : 554, 57 | "NOTE_D5" : 587, 58 | "NOTE_DS5" : 622, 59 | "NOTE_E5" : 659, 60 | "NOTE_F5" : 698, 61 | "NOTE_FS5" : 740, 62 | "NOTE_G5" : 784, 63 | "NOTE_GS5" : 831, 64 | "NOTE_A5" : 880, 65 | "NOTE_AS5" : 932, 66 | "NOTE_B5" : 988, 67 | "NOTE_C6" : 1047, 68 | "NOTE_CS6" : 1109, 69 | "NOTE_D6" : 1175, 70 | "NOTE_DS6" : 1245, 71 | "NOTE_E6" : 1319, 72 | "NOTE_F6" : 1397, 73 | "NOTE_FS6" : 1480, 74 | "NOTE_G6" : 1568, 75 | "NOTE_GS6" : 1661, 76 | "NOTE_A6" : 1760, 77 | "NOTE_AS6" : 1865, 78 | "NOTE_B6" : 1976, 79 | "NOTE_C7" : 2093, 80 | "NOTE_CS7" : 2217, 81 | "NOTE_D7" : 2349, 82 | "NOTE_DS7" : 2489, 83 | "NOTE_E7" : 2637, 84 | "NOTE_F7" : 2794, 85 | "NOTE_FS7" : 2960, 86 | "NOTE_G7" : 3136, 87 | "NOTE_GS7" : 3322, 88 | "NOTE_A7" : 3520, 89 | "NOTE_AS7" : 3729, 90 | "NOTE_B7" : 3951, 91 | "NOTE_C8" : 4186, 92 | "NOTE_CS8" : 4435, 93 | "NOTE_D8" : 4699, 94 | "NOTE_DS8" : 4978, 95 | "REST" : 0 96 | } 97 | 98 | 99 | def convertNote(filePath): 100 | print("start convert file: {}".format(filePath)) 101 | 102 | # Open and eplace 103 | buzz_music_file_content = open(filePath, mode='r').read() 104 | for key in noteTable: 105 | buzz_music_file_content = buzz_music_file_content.replace(key, str(noteTable[key])) 106 | 107 | # Save 108 | buzz_music_file = open(filePath, mode='w') 109 | buzz_music_file.write(buzz_music_file_content) 110 | buzz_music_file.close() 111 | 112 | 113 | if __name__=="__main__": 114 | print("buzz music converter > <") 115 | convertNote(sys.argv[1]) 116 | print("done") 117 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/buzz_music/happybirthday.json: -------------------------------------------------------------------------------- 1 | { 2 | "tempo": 140, 3 | "melody": [ 4 | 262, 4, 262, 8, 294, -4, 262, -4, 349, -4, 330, -2, 262, 4, 262, 8, 294, -4, 5 | 262, -4, 392, -4, 349, -2, 262, 4, 262, 8, 523, -4, 440, -4, 349, -4, 330, 6 | -4, 294, -4, 466, 4, 466, 8, 440, -4, 349, -4, 392, -4, 349, -2 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/buzz_music/harrypotter.json: -------------------------------------------------------------------------------- 1 | { 2 | "tempo": 144, 3 | "melody": [ 4 | 0, 2, 294, 4, 392, -4, 466, 8, 440, 4, 392, 2, 587, 4, 523, -2, 440, -2, 5 | 392, -4, 466, 8, 440, 4, 349, 2, 415, 4, 294, -1, 294, 4, 6 | 7 | 392, -4, 466, 8, 440, 4, 392, 2, 587, 4, 698, 2, 659, 4, 622, 2, 494, 4, 8 | 622, -4, 587, 8, 554, 4, 277, 2, 494, 4, 392, -1, 466, 4, 9 | 10 | 587, 2, 466, 4, 587, 2, 466, 4, 622, 2, 587, 4, 554, 2, 440, 4, 466, -4, 11 | 587, 8, 554, 4, 277, 2, 294, 4, 587, -1, 0, 4, 466, 4, 12 | 13 | 587, 2, 466, 4, 587, 2, 466, 4, 698, 2, 659, 4, 622, 2, 494, 4, 622, -4, 14 | 587, 8, 554, 4, 277, 2, 466, 4, 392, -1 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/buzz_music/nokia.json: -------------------------------------------------------------------------------- 1 | { 2 | "tempo": 180, 3 | "melody": [ 4 | 659, 8, 587, 8, 370, 4, 415, 4, 554, 8, 494, 8, 294, 4, 330, 4, 494, 8, 440, 5 | 8, 277, 4, 330, 4, 440, 2 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/buzz_music/starwars.json: -------------------------------------------------------------------------------- 1 | { 2 | "tempo": 108, 3 | "melody": [ 4 | 466, 8, 466, 8, 466, 8, 698, 2, 1047, 2, 932, 8, 880, 8, 784, 8, 1397, 2, 5 | 1047, 4, 932, 8, 880, 8, 784, 8, 1397, 2, 1047, 4, 932, 8, 880, 8, 932, 8, 6 | 784, 2, 523, 8, 523, 8, 523, 8, 698, 2, 1047, 2, 932, 8, 880, 8, 784, 8, 7 | 1397, 2, 1047, 4, 8 | 9 | 932, 8, 880, 8, 784, 8, 1397, 2, 1047, 4, 932, 8, 880, 8, 932, 8, 784, 2, 10 | 523, -8, 523, 16, 587, -4, 587, 8, 932, 8, 880, 8, 784, 8, 698, 8, 698, 8, 11 | 784, 8, 880, 8, 784, 4, 587, 8, 659, 4, 523, -8, 523, 16, 587, -4, 587, 8, 12 | 932, 8, 880, 8, 784, 8, 698, 8, 13 | 14 | 1047, -8, 784, 16, 784, 2, 0, 8, 523, 8, 587, -4, 587, 8, 932, 8, 880, 8, 15 | 784, 8, 698, 8, 698, 8, 784, 8, 880, 8, 784, 4, 587, 8, 659, 4, 1047, -8, 16 | 1047, 16, 1397, 4, 1245, 8, 1109, 4, 1047, 8, 932, 4, 831, 8, 784, 4, 698, 17 | 8, 1047, 1 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/rachel/apps/app_music/assets/buzz_music/supermariobros.json: -------------------------------------------------------------------------------- 1 | { 2 | "tempo": 200, 3 | "melody": [ 4 | 659, 8, 659, 8, 0, 8, 659, 8, 0, 8, 523, 8, 659, 8, 784, 4, 0, 4, 392, 8, 0, 5 | 4, 523, -4, 392, 8, 0, 4, 330, -4, 440, 4, 494, 4, 466, 8, 440, 4, 392, -8, 6 | 659, -8, 784, -8, 880, 4, 698, 8, 784, 8, 0, 8, 659, 4, 523, 8, 587, 8, 494, 7 | -4, 523, -4, 392, 8, 0, 4, 330, -4, 440, 4, 494, 4, 466, 8, 440, 4, 392, -8, 8 | 659, -8, 784, -8, 880, 4, 698, 8, 784, 8, 0, 8, 659, 4, 523, 8, 587, 8, 494, 9 | -4, 10 | 11 | 0, 4, 784, 8, 740, 8, 698, 8, 622, 4, 659, 8, 0, 8, 415, 8, 440, 8, 262, 8, 12 | 0, 8, 440, 8, 523, 8, 587, 8, 0, 4, 622, 4, 0, 8, 587, -4, 523, 2, 0, 2, 13 | 14 | 0, 4, 784, 8, 740, 8, 698, 8, 622, 4, 659, 8, 0, 8, 415, 8, 440, 8, 262, 8, 15 | 0, 8, 440, 8, 523, 8, 587, 8, 0, 4, 622, 4, 0, 8, 587, -4, 523, 2, 0, 2, 16 | 17 | 523, 8, 523, 4, 523, 8, 0, 8, 523, 8, 587, 4, 659, 8, 523, 4, 440, 8, 392, 18 | 2, 19 | 20 | 523, 8, 523, 4, 523, 8, 0, 8, 523, 8, 587, 8, 659, 8, 0, 1, 523, 8, 523, 4, 21 | 523, 8, 0, 8, 523, 8, 587, 4, 659, 8, 523, 4, 440, 8, 392, 2, 659, 8, 659, 22 | 8, 0, 8, 659, 8, 0, 8, 523, 8, 659, 4, 784, 4, 0, 4, 392, 4, 0, 4, 523, -4, 23 | 392, 8, 0, 4, 330, -4, 24 | 25 | 440, 4, 494, 4, 466, 8, 440, 4, 392, -8, 659, -8, 784, -8, 880, 4, 698, 8, 26 | 784, 8, 0, 8, 659, 4, 523, 8, 587, 8, 494, -4, 27 | 28 | 523, -4, 392, 8, 0, 4, 330, -4, 440, 4, 494, 4, 466, 8, 440, 4, 392, -8, 29 | 659, -8, 784, -8, 880, 4, 698, 8, 784, 8, 0, 8, 659, 4, 523, 8, 587, 8, 494, 30 | -4, 31 | 32 | 659, 8, 523, 4, 392, 8, 0, 4, 415, 4, 440, 8, 698, 4, 698, 8, 440, 2, 587, 33 | -8, 880, -8, 880, -8, 880, -8, 784, -8, 698, -8, 34 | 35 | 659, 8, 523, 4, 440, 8, 392, 2, 659, 8, 523, 4, 392, 8, 0, 4, 415, 4, 440, 36 | 8, 698, 4, 698, 8, 440, 2, 494, 8, 698, 4, 698, 8, 698, -8, 659, -8, 587, 37 | -8, 523, 8, 330, 4, 330, 8, 262, 2, 38 | 39 | 659, 8, 523, 4, 392, 8, 0, 4, 415, 4, 440, 8, 698, 4, 698, 8, 440, 2, 587, 40 | -8, 880, -8, 880, -8, 880, -8, 784, -8, 698, -8, 41 | 42 | 659, 8, 523, 4, 440, 8, 392, 2, 659, 8, 523, 4, 392, 8, 0, 4, 415, 4, 440, 43 | 8, 698, 4, 698, 8, 440, 2, 494, 8, 698, 4, 698, 8, 698, -8, 659, -8, 587, 44 | -8, 523, 8, 330, 4, 330, 8, 262, 2, 523, 8, 523, 4, 523, 8, 0, 8, 523, 8, 45 | 587, 8, 659, 8, 0, 1, 46 | 47 | 523, 8, 523, 4, 523, 8, 0, 8, 523, 8, 587, 4, 659, 8, 523, 4, 440, 8, 392, 48 | 2, 659, 8, 659, 8, 0, 8, 659, 8, 0, 8, 523, 8, 659, 4, 784, 4, 0, 4, 392, 4, 49 | 0, 4, 659, 8, 523, 4, 392, 8, 0, 4, 415, 4, 440, 8, 698, 4, 698, 8, 440, 2, 50 | 587, -8, 880, -8, 880, -8, 880, -8, 784, -8, 698, -8, 51 | 52 | 659, 8, 523, 4, 440, 8, 392, 2, 659, 8, 523, 4, 392, 8, 0, 4, 415, 4, 440, 53 | 8, 698, 4, 698, 8, 440, 2, 494, 8, 698, 4, 698, 8, 698, -8, 659, -8, 587, 54 | -8, 523, 8, 330, 4, 330, 8, 262, 2, 55 | 56 | 523, -4, 392, -4, 330, 4, 440, -8, 494, -8, 440, -8, 415, -8, 466, -8, 415, 57 | -8, 392, 8, 294, 8, 330, -2 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/app_nofrendo.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_nofrendo.cpp 3 | * @author Forairaaaaa 4 | * @brief Ref: https://github.com/pebri86/esplay-retro-emulation/tree/master 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_nofrendo.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | extern "C" 16 | { 17 | #include "nofrendo/nofrendo.h" 18 | } 19 | 20 | using namespace MOONCAKE::APPS; 21 | 22 | void AppNofrendo::onCreate() { spdlog::info("{} onCreate", getAppName()); } 23 | 24 | void AppNofrendo::onResume() 25 | { 26 | spdlog::info("{} onResume", getAppName()); 27 | HAL::GetCanvas()->fillScreen(TFT_BLACK); 28 | HAL::CanvasUpdate(); 29 | } 30 | 31 | void AppNofrendo::onRunning() 32 | { 33 | #ifdef ESP_PLATFORM 34 | nofrendo_main(0, NULL); 35 | #else 36 | HAL::PopFatalError("懒得抽象了"); 37 | #endif 38 | } 39 | 40 | void AppNofrendo::onDestroy() { spdlog::info("{} onDestroy", getAppName()); } 41 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/app_nofrendo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_nofrendo.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_nofrendo.hpp" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Nofrendo 18 | * 19 | */ 20 | class AppNofrendo : public APP_BASE 21 | { 22 | public: 23 | void onCreate() override; 24 | void onResume() override; 25 | void onRunning() override; 26 | void onDestroy() override; 27 | }; 28 | 29 | class AppNofrendo_Packer : public APP_PACKER_BASE 30 | { 31 | std::string getAppName() override { return "Nofrendo"; } 32 | void* getAppIcon() override { return (void*)image_data_icon_app_nofrendo; } 33 | void* newApp() override { return new AppNofrendo; } 34 | void deleteApp(void* app) override { delete (AppNofrendo*)app; } 35 | }; 36 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo-esp32/osd.c: -------------------------------------------------------------------------------- 1 | /* vim: set tabstop=3 expandtab: 2 | ** 3 | ** This file is in the public domain. 4 | ** 5 | ** osd.c 6 | ** 7 | ** $Id: osd.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 8 | ** 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | char configfilename[] = "na"; 32 | 33 | /* This is os-specific part of main() */ 34 | int osd_main(int argc, char* argv[]) 35 | { 36 | config.filename = configfilename; 37 | 38 | return main_loop("rom", system_nes); 39 | } 40 | 41 | /* File system interface */ 42 | void osd_fullname(char* fullname, const char* shortname) { strncpy(fullname, shortname, PATH_MAX); } 43 | 44 | /* This gives filenames for storage of saves */ 45 | char* osd_newextension(char* string, char* ext) { return string; } 46 | 47 | /* This gives filenames for storage of PCX snapshots */ 48 | int osd_makesnapname(char* filename, int len) { return -1; } 49 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo-esp32/port.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file port.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-15 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | 14 | void nofendo_render_frame(const uint8_t* data[]); 15 | void nofendo_pause_menu(); 16 | uint8_t nofendo_get_btn_a(); 17 | uint8_t nofendo_get_btn_b(); 18 | uint8_t nofendo_get_btn_select(); 19 | uint8_t nofendo_get_btn_start(); 20 | uint8_t nofendo_get_btn_right(); 21 | uint8_t nofendo_get_btn_left(); 22 | uint8_t nofendo_get_btn_up(); 23 | uint8_t nofendo_get_btn_down(); 24 | uint8_t nofendo_get_btn_x(); 25 | uint8_t nofendo_get_btn_y(); 26 | char* nofendo_get_rom(); 27 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/AUTHORS: -------------------------------------------------------------------------------- 1 | Matt Conte 2 | Just about everything 3 | 4 | Neil Stevens 5 | SDL, automake, current maintainer 6 | 7 | Firebug 8 | mapper support, testing 9 | 10 | Benjamin C. W. Sittler 11 | config code 12 | 13 | The Mighty Mike Master 14 | mapper 231 code 15 | 16 | Jeroen Domburg 17 | Mangling the code to make it into an esp-idf component 18 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** bitmap.h 21 | ** 22 | ** Bitmap object defines / prototypes 23 | ** $Id: bitmap.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _BITMAP_H_ 27 | #define _BITMAP_H_ 28 | 29 | #include 30 | 31 | /* a bitmap rectangle */ 32 | typedef struct rect_s 33 | { 34 | int16 x, y; 35 | uint16 w, h; 36 | } rect_t; 37 | 38 | typedef struct rgb_s 39 | { 40 | int r, g, b; 41 | } rgb_t; 42 | 43 | typedef struct bitmap_s 44 | { 45 | int width, height, pitch; 46 | bool hardware; /* is data a hardware region? */ 47 | uint8* data; /* protected */ 48 | uint8* line[ZERO_LENGTH]; /* will hold line pointers */ 49 | } bitmap_t; 50 | 51 | extern void bmp_clear(const bitmap_t* bitmap, uint8 color); 52 | extern bitmap_t* bmp_create(int width, int height, int overdraw); 53 | extern bitmap_t* bmp_createhw(uint8* addr, int width, int height, int pitch); 54 | extern void bmp_destroy(bitmap_t** bitmap); 55 | 56 | #endif /* _BITMAP_H_ */ 57 | 58 | /* 59 | ** $Log: bitmap.h,v $ 60 | ** Revision 1.2 2001/04/27 14:37:11 neil 61 | ** wheeee 62 | ** 63 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 64 | ** initial 65 | ** 66 | ** Revision 1.12 2000/11/05 16:37:18 matt 67 | ** rolled rgb.h into bitmap.h 68 | ** 69 | ** Revision 1.11 2000/10/10 13:58:13 matt 70 | ** stroustrup squeezing his way in the door 71 | ** 72 | ** Revision 1.10 2000/09/18 02:06:48 matt 73 | ** -pedantic is your friend 74 | ** 75 | ** Revision 1.9 2000/07/31 04:28:46 matt 76 | ** one million cleanups 77 | ** 78 | ** Revision 1.8 2000/07/24 04:31:43 matt 79 | ** pitch/data area on non-hw bitmaps get padded to 32-bit boundaries 80 | ** 81 | ** Revision 1.7 2000/07/17 01:52:27 matt 82 | ** made sure last line of all source files is a newline 83 | ** 84 | ** Revision 1.6 2000/07/09 14:43:01 matt 85 | ** pitch is now configurable for bmp_createhw() 86 | ** 87 | ** Revision 1.5 2000/07/06 16:46:57 matt 88 | ** added bmp_clear() routine 89 | ** 90 | ** Revision 1.4 2000/06/09 15:12:25 matt 91 | ** initial revision 92 | ** 93 | */ 94 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/cpu/dis6502.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** dis6502.h 21 | ** 22 | ** 6502 disassembler header 23 | ** $Id: dis6502.h,v 1.1 2001/04/27 12:54:39 neil Exp $ 24 | */ 25 | 26 | #ifndef _DIS6502_H_ 27 | #define _DIS6502_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" 31 | { 32 | #endif /* __cplusplus */ 33 | 34 | extern char* nes6502_disasm(uint32 PC, uint8 P, uint8 A, uint8 X, uint8 Y, uint8 S); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif /* __cplusplus */ 39 | 40 | #endif /* !_DIS6502_H_ */ 41 | 42 | /* 43 | ** $Log: dis6502.h,v $ 44 | ** Revision 1.1 2001/04/27 12:54:39 neil 45 | ** blah 46 | ** 47 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 48 | ** initial 49 | ** 50 | ** Revision 1.6 2000/07/17 01:52:28 matt 51 | ** made sure last line of all source files is a newline 52 | ** 53 | ** Revision 1.5 2000/07/11 04:26:23 matt 54 | ** rewrote to fill up a static buffer, rather than use log_printf 55 | ** 56 | ** Revision 1.4 2000/06/09 15:12:25 matt 57 | ** initial revision 58 | ** 59 | */ 60 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/gui_elem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** gui_elem.h 21 | ** 22 | ** GUI elements (font, mouse pointer, etc.) 23 | ** $Id: gui_elem.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _GUI_ELEM_H_ 27 | #define _GUI_ELEM_H_ 28 | 29 | typedef struct fontchar_s 30 | { 31 | uint8 lines[6]; 32 | uint8 spacing; 33 | } fontchar_t; 34 | 35 | typedef struct font_s 36 | { 37 | const fontchar_t* character; 38 | uint8 height; 39 | } font_t; 40 | 41 | extern font_t small; 42 | 43 | #define CURSOR_WIDTH 11 44 | #define CURSOR_HEIGHT 19 45 | 46 | extern const uint8 cursor_color[]; 47 | extern const uint8 cursor[]; 48 | 49 | #endif /* _GUI_ELEM_H_ */ 50 | 51 | /* 52 | ** $Log: gui_elem.h,v $ 53 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 54 | ** initial 55 | ** 56 | ** Revision 1.7 2000/10/10 13:03:54 matt 57 | ** Mr. Clean makes a guest appearance 58 | ** 59 | ** Revision 1.6 2000/07/31 04:28:46 matt 60 | ** one million cleanups 61 | ** 62 | ** Revision 1.5 2000/07/17 01:52:27 matt 63 | ** made sure last line of all source files is a newline 64 | ** 65 | ** Revision 1.4 2000/06/09 15:12:25 matt 66 | ** initial revision 67 | ** 68 | */ 69 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/intro.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** intro.h 21 | ** 22 | ** Nofrendo intro -- 6502 code 23 | ** $Id: intro.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _INTRO_H_ 27 | #define _INTRO_H_ 28 | 29 | #include 30 | 31 | extern void intro_get_header(rominfo_t* rominfo); 32 | extern int intro_get_rom(rominfo_t* rominfo); 33 | 34 | #endif /* !_INTRO_H_ */ 35 | 36 | /* 37 | ** $Log: intro.h,v $ 38 | ** Revision 1.2 2001/04/27 14:37:11 neil 39 | ** wheeee 40 | ** 41 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 42 | ** initial 43 | ** 44 | ** Revision 1.3 2000/10/25 00:23:16 matt 45 | ** makefiles updated for new directory structure 46 | ** 47 | ** Revision 1.2 2000/10/10 13:03:54 matt 48 | ** Mr. Clean makes a guest appearance 49 | ** 50 | ** Revision 1.1 2000/07/30 04:29:11 matt 51 | ** initial revision 52 | ** 53 | */ 54 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** log.h 21 | ** 22 | ** Error logging header file 23 | ** $Id: log.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _LOG_H_ 27 | #define _LOG_H_ 28 | 29 | #include 30 | 31 | extern int log_init(void); 32 | extern void log_shutdown(void); 33 | extern int log_print(const char* string); 34 | extern int ___log_printf(const char* format, ...); 35 | extern void log_chain_logfunc(int (*logfunc)(const char* string)); 36 | extern void log_assert(int expr, int line, const char* file, char* msg); 37 | 38 | #endif /* _LOG_H_ */ 39 | 40 | /* 41 | ** $Log: log.h,v $ 42 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 43 | ** initial 44 | ** 45 | ** Revision 1.7 2000/11/06 02:15:07 matt 46 | ** more robust logging routines 47 | ** 48 | ** Revision 1.6 2000/10/10 13:03:54 matt 49 | ** Mr. Clean makes a guest appearance 50 | ** 51 | ** Revision 1.5 2000/07/17 01:52:27 matt 52 | ** made sure last line of all source files is a newline 53 | ** 54 | ** Revision 1.4 2000/06/09 15:12:25 matt 55 | ** initial revision 56 | ** 57 | */ 58 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map000.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map0.c 21 | ** 22 | ** mapper 0 interface 23 | ** $Id: map000.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | mapintf_t map0_intf = { 30 | 0, /* mapper number */ 31 | "None", /* mapper name */ 32 | NULL, /* init routine */ 33 | NULL, /* vblank callback */ 34 | NULL, /* hblank callback */ 35 | NULL, /* get state (snss) */ 36 | NULL, /* set state (snss) */ 37 | NULL, /* memory read structure */ 38 | NULL, /* memory write structure */ 39 | NULL /* external sound device */ 40 | }; 41 | 42 | /* 43 | ** $Log: map000.c,v $ 44 | ** Revision 1.2 2001/04/27 14:37:11 neil 45 | ** wheeee 46 | ** 47 | ** Revision 1.1 2001/04/27 12:54:40 neil 48 | ** blah 49 | ** 50 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 51 | ** initial 52 | ** 53 | ** Revision 1.1 2000/10/24 12:19:32 matt 54 | ** changed directory structure 55 | ** 56 | ** Revision 1.2 2000/07/06 02:48:43 matt 57 | ** clearly labelled structure members 58 | ** 59 | ** Revision 1.1 2000/07/04 23:11:45 matt 60 | ** initial revision 61 | ** 62 | */ 63 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map002.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map2.c 21 | ** 22 | ** mapper 2 interface 23 | ** $Id: map002.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 2: UNROM */ 30 | static void map2_init() 31 | { 32 | int last_bank = mmc_getinfo()->rom_banks - 1; 33 | printf("map2_init. last_bank=%d\n", last_bank); 34 | mmc_bankrom(16, 0xc000, last_bank); 35 | mmc_bankrom(16, 0x8000, 0); 36 | } 37 | 38 | static void map2_write(uint32 address, uint8 value) 39 | { 40 | UNUSED(address); 41 | 42 | mmc_bankrom(16, 0x8000, value); 43 | } 44 | 45 | static map_memwrite map2_memwrite[] = {{0x8000, 0xFFFF, map2_write}, {-1, -1, NULL}}; 46 | 47 | mapintf_t map2_intf = { 48 | 2, /* mapper number */ 49 | "UNROM", /* mapper name */ 50 | map2_init, /* init routine */ 51 | NULL, /* vblank callback */ 52 | NULL, /* hblank callback */ 53 | NULL, /* get state (snss) */ 54 | NULL, /* set state (snss) */ 55 | NULL, /* memory read structure */ 56 | map2_memwrite, /* memory write structure */ 57 | NULL /* external sound device */ 58 | }; 59 | 60 | /* 61 | ** $Log: map002.c,v $ 62 | ** Revision 1.2 2001/04/27 14:37:11 neil 63 | ** wheeee 64 | ** 65 | ** Revision 1.1 2001/04/27 12:54:40 neil 66 | ** blah 67 | ** 68 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 69 | ** initial 70 | ** 71 | ** Revision 1.1 2000/10/24 12:19:32 matt 72 | ** changed directory structure 73 | ** 74 | ** Revision 1.5 2000/10/22 19:17:46 matt 75 | ** mapper cleanups galore 76 | ** 77 | ** Revision 1.4 2000/10/21 19:33:38 matt 78 | ** many more cleanups 79 | ** 80 | ** Revision 1.3 2000/08/16 02:50:11 matt 81 | ** random mapper cleanups 82 | ** 83 | ** Revision 1.2 2000/07/06 02:48:43 matt 84 | ** clearly labelled structure members 85 | ** 86 | ** Revision 1.1 2000/07/04 23:11:45 matt 87 | ** initial revision 88 | ** 89 | */ 90 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map003.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map3.c 21 | ** 22 | ** mapper 3 interface 23 | ** $Id: map003.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 3: CNROM */ 30 | static void map3_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankvrom(8, 0x0000, value); 35 | } 36 | 37 | static map_memwrite map3_memwrite[] = {{0x8000, 0xFFFF, map3_write}, {-1, -1, NULL}}; 38 | 39 | mapintf_t map3_intf = { 40 | 3, /* mapper number */ 41 | "CNROM", /* mapper name */ 42 | NULL, /* init routine */ 43 | NULL, /* vblank callback */ 44 | NULL, /* hblank callback */ 45 | NULL, /* get state (snss) */ 46 | NULL, /* set state (snss) */ 47 | NULL, /* memory read structure */ 48 | map3_memwrite, /* memory write structure */ 49 | NULL /* external sound device */ 50 | }; 51 | 52 | /* 53 | ** $Log: map003.c,v $ 54 | ** Revision 1.2 2001/04/27 14:37:11 neil 55 | ** wheeee 56 | ** 57 | ** Revision 1.1 2001/04/27 12:54:40 neil 58 | ** blah 59 | ** 60 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 61 | ** initial 62 | ** 63 | ** Revision 1.1 2000/10/24 12:19:32 matt 64 | ** changed directory structure 65 | ** 66 | ** Revision 1.5 2000/10/22 19:17:46 matt 67 | ** mapper cleanups galore 68 | ** 69 | ** Revision 1.4 2000/10/21 19:33:38 matt 70 | ** many more cleanups 71 | ** 72 | ** Revision 1.3 2000/08/16 02:50:11 matt 73 | ** random mapper cleanups 74 | ** 75 | ** Revision 1.2 2000/07/06 02:48:43 matt 76 | ** clearly labelled structure members 77 | ** 78 | ** Revision 1.1 2000/07/04 23:11:45 matt 79 | ** initial revision 80 | ** 81 | */ 82 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map007.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map7.c 21 | ** 22 | ** mapper 7 interface 23 | ** $Id: map007.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /* mapper 7: AOROM */ 32 | static void map7_write(uint32 address, uint8 value) 33 | { 34 | int mirror; 35 | UNUSED(address); 36 | 37 | mmc_bankrom(32, 0x8000, value); 38 | mirror = (value & 0x10) >> 4; 39 | ppu_mirror(mirror, mirror, mirror, mirror); 40 | } 41 | 42 | static void map7_init(void) { mmc_bankrom(32, 0x8000, 0); } 43 | 44 | static map_memwrite map7_memwrite[] = {{0x8000, 0xFFFF, map7_write}, {-1, -1, NULL}}; 45 | 46 | mapintf_t map7_intf = { 47 | 7, /* mapper number */ 48 | "AOROM", /* mapper name */ 49 | map7_init, /* init routine */ 50 | NULL, /* vblank callback */ 51 | NULL, /* hblank callback */ 52 | NULL, /* get state (snss) */ 53 | NULL, /* set state (snss) */ 54 | NULL, /* memory read structure */ 55 | map7_memwrite, /* memory write structure */ 56 | NULL /* external sound device */ 57 | }; 58 | 59 | /* 60 | ** $Log: map007.c,v $ 61 | ** Revision 1.2 2001/04/27 14:37:11 neil 62 | ** wheeee 63 | ** 64 | ** Revision 1.1 2001/04/27 12:54:40 neil 65 | ** blah 66 | ** 67 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 68 | ** initial 69 | ** 70 | ** Revision 1.1 2000/10/24 12:19:32 matt 71 | ** changed directory structure 72 | ** 73 | ** Revision 1.6 2000/10/22 19:17:46 matt 74 | ** mapper cleanups galore 75 | ** 76 | ** Revision 1.5 2000/10/22 15:03:13 matt 77 | ** simplified mirroring 78 | ** 79 | ** Revision 1.4 2000/10/21 19:33:38 matt 80 | ** many more cleanups 81 | ** 82 | ** Revision 1.3 2000/08/16 02:50:11 matt 83 | ** random mapper cleanups 84 | ** 85 | ** Revision 1.2 2000/07/06 02:48:43 matt 86 | ** clearly labelled structure members 87 | ** 88 | ** Revision 1.1 2000/07/04 23:11:45 matt 89 | ** initial revision 90 | ** 91 | */ 92 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map008.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map8.c 21 | ** 22 | ** mapper 8 interface 23 | ** $Id: map008.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 8: FFE F3xxx -- what the hell uses this? */ 30 | static void map8_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(16, 0x8000, value >> 3); 35 | mmc_bankvrom(8, 0x0000, value & 7); 36 | } 37 | 38 | static void map8_init(void) 39 | { 40 | mmc_bankrom(16, 0x8000, 0); 41 | mmc_bankrom(16, 0xC000, 1); 42 | mmc_bankvrom(8, 0x0000, 0); 43 | } 44 | 45 | static map_memwrite map8_memwrite[] = {{0x8000, 0xFFFF, map8_write}, {-1, -1, NULL}}; 46 | 47 | mapintf_t map8_intf = { 48 | 8, /* mapper number */ 49 | "FFE F3xxx", /* mapper name */ 50 | map8_init, /* init routine */ 51 | NULL, /* vblank callback */ 52 | NULL, /* hblank callback */ 53 | NULL, /* get state (snss) */ 54 | NULL, /* set state (snss) */ 55 | NULL, /* memory read structure */ 56 | map8_memwrite, /* memory write structure */ 57 | NULL /* external sound device */ 58 | }; 59 | 60 | /* 61 | ** $Log: map008.c,v $ 62 | ** Revision 1.2 2001/04/27 14:37:11 neil 63 | ** wheeee 64 | ** 65 | ** Revision 1.1 2001/04/27 12:54:40 neil 66 | ** blah 67 | ** 68 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 69 | ** initial 70 | ** 71 | ** Revision 1.1 2000/10/24 12:19:32 matt 72 | ** changed directory structure 73 | ** 74 | ** Revision 1.5 2000/10/22 19:17:47 matt 75 | ** mapper cleanups galore 76 | ** 77 | ** Revision 1.4 2000/10/21 19:33:38 matt 78 | ** many more cleanups 79 | ** 80 | ** Revision 1.3 2000/08/16 02:50:11 matt 81 | ** random mapper cleanups 82 | ** 83 | ** Revision 1.2 2000/07/06 02:48:43 matt 84 | ** clearly labelled structure members 85 | ** 86 | ** Revision 1.1 2000/07/04 23:11:45 matt 87 | ** initial revision 88 | ** 89 | */ 90 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map011.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map11.c 21 | ** 22 | ** mapper 11 interface 23 | ** $Id: map011.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 11: Color Dreams, Wisdom Tree */ 30 | static void map11_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(32, 0x8000, value & 0x0F); 35 | mmc_bankvrom(8, 0x0000, value >> 4); 36 | } 37 | 38 | static void map11_init(void) 39 | { 40 | mmc_bankrom(32, 0x8000, 0); 41 | mmc_bankvrom(8, 0x0000, 0); 42 | } 43 | 44 | static map_memwrite map11_memwrite[] = {{0x8000, 0xFFFF, map11_write}, {-1, -1, NULL}}; 45 | 46 | mapintf_t map11_intf = { 47 | 11, /* mapper number */ 48 | "Color Dreams", /* mapper name */ 49 | map11_init, /* init routine */ 50 | NULL, /* vblank callback */ 51 | NULL, /* hblank callback */ 52 | NULL, /* get state (snss) */ 53 | NULL, /* set state (snss) */ 54 | NULL, /* memory read structure */ 55 | map11_memwrite, /* memory write structure */ 56 | NULL /* external sound device */ 57 | }; 58 | 59 | /* 60 | ** $Log: map011.c,v $ 61 | ** Revision 1.2 2001/04/27 14:37:11 neil 62 | ** wheeee 63 | ** 64 | ** Revision 1.1 2001/04/27 12:54:40 neil 65 | ** blah 66 | ** 67 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 68 | ** initial 69 | ** 70 | ** Revision 1.1 2000/10/24 12:19:33 matt 71 | ** changed directory structure 72 | ** 73 | ** Revision 1.5 2000/10/22 19:17:46 matt 74 | ** mapper cleanups galore 75 | ** 76 | ** Revision 1.4 2000/10/21 19:33:38 matt 77 | ** many more cleanups 78 | ** 79 | ** Revision 1.3 2000/08/16 02:50:11 matt 80 | ** random mapper cleanups 81 | ** 82 | ** Revision 1.2 2000/07/06 02:48:43 matt 83 | ** clearly labelled structure members 84 | ** 85 | ** Revision 1.1 2000/07/04 23:11:45 matt 86 | ** initial revision 87 | ** 88 | */ 89 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map032.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map32.c 21 | ** 22 | ** mapper 32 interface 23 | ** $Id: map032.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static int select_c000 = 0; 31 | 32 | /* mapper 32: Irem G-101 */ 33 | static void map32_write(uint32 address, uint8 value) 34 | { 35 | switch (address >> 12) 36 | { 37 | case 0x08: 38 | if (select_c000) 39 | mmc_bankrom(8, 0xC000, value); 40 | else 41 | mmc_bankrom(8, 0x8000, value); 42 | break; 43 | 44 | case 0x09: 45 | if (value & 1) 46 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 47 | else 48 | ppu_mirror(0, 1, 0, 1); /* vertical */ 49 | 50 | select_c000 = (value & 0x02); 51 | break; 52 | 53 | case 0x0A: 54 | mmc_bankrom(8, 0xA000, value); 55 | break; 56 | 57 | case 0x0B: 58 | { 59 | int loc = (address & 0x07) << 10; 60 | mmc_bankvrom(1, loc, value); 61 | } 62 | break; 63 | 64 | default: 65 | break; 66 | } 67 | } 68 | 69 | static map_memwrite map32_memwrite[] = {{0x8000, 0xFFFF, map32_write}, {-1, -1, NULL}}; 70 | 71 | mapintf_t map32_intf = { 72 | 32, /* mapper number */ 73 | "Irem G-101", /* mapper name */ 74 | NULL, /* init routine */ 75 | NULL, /* vblank callback */ 76 | NULL, /* hblank callback */ 77 | NULL, /* get state (snss) */ 78 | NULL, /* set state (snss) */ 79 | NULL, /* memory read structure */ 80 | map32_memwrite, /* memory write structure */ 81 | NULL /* external sound device */ 82 | }; 83 | 84 | /* 85 | ** $Log: map032.c,v $ 86 | ** Revision 1.2 2001/04/27 14:37:11 neil 87 | ** wheeee 88 | ** 89 | ** Revision 1.1 2001/04/27 12:54:40 neil 90 | ** blah 91 | ** 92 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 93 | ** initial 94 | ** 95 | ** Revision 1.1 2000/10/24 12:19:33 matt 96 | ** changed directory structure 97 | ** 98 | ** Revision 1.6 2000/10/22 19:17:46 matt 99 | ** mapper cleanups galore 100 | ** 101 | ** Revision 1.5 2000/10/22 15:03:13 matt 102 | ** simplified mirroring 103 | ** 104 | ** Revision 1.4 2000/10/21 19:33:38 matt 105 | ** many more cleanups 106 | ** 107 | ** Revision 1.3 2000/07/10 05:29:03 matt 108 | ** cleaned up some mirroring issues 109 | ** 110 | ** Revision 1.2 2000/07/06 02:48:43 matt 111 | ** clearly labelled structure members 112 | ** 113 | ** Revision 1.1 2000/07/06 01:01:56 matt 114 | ** initial revision 115 | ** 116 | */ 117 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map034.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map34.c 21 | ** 22 | ** mapper 34 interface 23 | ** $Id: map034.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | static void map34_init(void) { mmc_bankrom(32, 0x8000, MMC_LASTBANK); } 30 | 31 | static void map34_write(uint32 address, uint8 value) 32 | { 33 | if ((address & 0x8000) || (0x7FFD == address)) 34 | { 35 | mmc_bankrom(32, 0x8000, value); 36 | } 37 | else if (0x7FFE == address) 38 | { 39 | mmc_bankvrom(4, 0x0000, value); 40 | } 41 | else if (0x7FFF == address) 42 | { 43 | mmc_bankvrom(4, 0x1000, value); 44 | } 45 | } 46 | 47 | static map_memwrite map34_memwrite[] = {{0x7FFD, 0xFFFF, map34_write}, {-1, -1, NULL}}; 48 | 49 | mapintf_t map34_intf = { 50 | 34, /* mapper number */ 51 | "Nina-1", /* mapper name */ 52 | map34_init, /* init routine */ 53 | NULL, /* vblank callback */ 54 | NULL, /* hblank callback */ 55 | NULL, /* get state (snss) */ 56 | NULL, /* set state (snss) */ 57 | NULL, /* memory read structure */ 58 | map34_memwrite, /* memory write structure */ 59 | NULL /* external sound device */ 60 | }; 61 | 62 | /* 63 | ** $Log: map034.c,v $ 64 | ** Revision 1.2 2001/04/27 14:37:11 neil 65 | ** wheeee 66 | ** 67 | ** Revision 1.1 2001/04/27 12:54:40 neil 68 | ** blah 69 | ** 70 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 71 | ** initial 72 | ** 73 | ** Revision 1.1 2000/10/24 12:19:33 matt 74 | ** changed directory structure 75 | ** 76 | ** Revision 1.5 2000/10/22 19:17:46 matt 77 | ** mapper cleanups galore 78 | ** 79 | ** Revision 1.4 2000/10/21 19:33:38 matt 80 | ** many more cleanups 81 | ** 82 | ** Revision 1.3 2000/07/11 05:03:49 matt 83 | ** value masking isn't necessary for the banking routines 84 | ** 85 | ** Revision 1.2 2000/07/11 03:35:08 bsittler 86 | ** Fixes to make mikes new mappers compile. 87 | ** 88 | ** Revision 1.1 2000/07/11 03:14:18 melanson 89 | ** Initial commit for mappers 16, 34, and 231 90 | ** 91 | ** 92 | */ 93 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map066.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map66.c 21 | ** 22 | ** mapper 66 interface 23 | ** $Id: map066.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 66: GNROM */ 30 | static void map66_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(32, 0x8000, (value >> 4) & 3); 35 | mmc_bankvrom(8, 0x0000, value & 3); 36 | } 37 | 38 | static void map66_init(void) 39 | { 40 | mmc_bankrom(32, 0x8000, 0); 41 | mmc_bankvrom(8, 0x0000, 0); 42 | } 43 | 44 | static map_memwrite map66_memwrite[] = {{0x8000, 0xFFFF, map66_write}, {-1, -1, NULL}}; 45 | 46 | mapintf_t map66_intf = { 47 | 66, /* mapper number */ 48 | "GNROM", /* mapper name */ 49 | map66_init, /* init routine */ 50 | NULL, /* vblank callback */ 51 | NULL, /* hblank callback */ 52 | NULL, /* get state (snss) */ 53 | NULL, /* set state (snss) */ 54 | NULL, /* memory read structure */ 55 | map66_memwrite, /* memory write structure */ 56 | NULL /* external sound device */ 57 | }; 58 | 59 | /* 60 | ** $Log: map066.c,v $ 61 | ** Revision 1.2 2001/04/27 14:37:11 neil 62 | ** wheeee 63 | ** 64 | ** Revision 1.1 2001/04/27 12:54:40 neil 65 | ** blah 66 | ** 67 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 68 | ** initial 69 | ** 70 | ** Revision 1.1 2000/10/24 12:19:33 matt 71 | ** changed directory structure 72 | ** 73 | ** Revision 1.5 2000/10/22 19:17:46 matt 74 | ** mapper cleanups galore 75 | ** 76 | ** Revision 1.4 2000/10/21 19:33:38 matt 77 | ** many more cleanups 78 | ** 79 | ** Revision 1.3 2000/08/16 02:50:11 matt 80 | ** random mapper cleanups 81 | ** 82 | ** Revision 1.2 2000/07/06 02:48:43 matt 83 | ** clearly labelled structure members 84 | ** 85 | ** Revision 1.1 2000/07/05 05:05:18 matt 86 | ** initial revision 87 | ** 88 | */ 89 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map078.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map78.c 21 | ** 22 | ** mapper 78 interface 23 | ** $Id: map078.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* mapper 78: Holy Diver, Cosmo Carrier */ 31 | /* ($8000-$FFFF) D2-D0 = switch $8000-$BFFF */ 32 | /* ($8000-$FFFF) D7-D4 = switch PPU $0000-$1FFF */ 33 | /* ($8000-$FFFF) D3 = switch mirroring */ 34 | static void map78_write(uint32 address, uint8 value) 35 | { 36 | UNUSED(address); 37 | 38 | mmc_bankrom(16, 0x8000, value & 7); 39 | mmc_bankvrom(8, 0x0000, (value >> 4) & 0x0F); 40 | 41 | /* Ugh! Same abuse of the 4-screen bit as with Mapper #70 */ 42 | if (mmc_getinfo()->flags & ROM_FLAG_FOURSCREEN) 43 | { 44 | if (value & 0x08) 45 | ppu_mirror(0, 1, 0, 1); /* vert */ 46 | else 47 | ppu_mirror(0, 0, 1, 1); /* horiz */ 48 | } 49 | else 50 | { 51 | int mirror = (value >> 3) & 1; 52 | ppu_mirror(mirror, mirror, mirror, mirror); 53 | } 54 | } 55 | 56 | static map_memwrite map78_memwrite[] = {{0x8000, 0xFFFF, map78_write}, {-1, -1, NULL}}; 57 | 58 | mapintf_t map78_intf = { 59 | 78, /* mapper number */ 60 | "Mapper 78", /* mapper name */ 61 | NULL, /* init routine */ 62 | NULL, /* vblank callback */ 63 | NULL, /* hblank callback */ 64 | NULL, /* get state (snss) */ 65 | NULL, /* set state (snss) */ 66 | NULL, /* memory read structure */ 67 | map78_memwrite, /* memory write structure */ 68 | NULL /* external sound device */ 69 | }; 70 | 71 | /* 72 | ** $Log: map078.c,v $ 73 | ** Revision 1.2 2001/04/27 14:37:11 neil 74 | ** wheeee 75 | ** 76 | ** Revision 1.1 2001/04/27 12:54:40 neil 77 | ** blah 78 | ** 79 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 80 | ** initial 81 | ** 82 | ** Revision 1.1 2000/10/24 12:19:33 matt 83 | ** changed directory structure 84 | ** 85 | ** Revision 1.7 2000/10/22 19:17:46 matt 86 | ** mapper cleanups galore 87 | ** 88 | ** Revision 1.6 2000/10/22 15:03:14 matt 89 | ** simplified mirroring 90 | ** 91 | ** Revision 1.5 2000/10/21 19:33:38 matt 92 | ** many more cleanups 93 | ** 94 | ** Revision 1.4 2000/08/16 02:50:11 matt 95 | ** random mapper cleanups 96 | ** 97 | ** Revision 1.3 2000/07/10 05:29:03 matt 98 | ** cleaned up some mirroring issues 99 | ** 100 | ** Revision 1.2 2000/07/06 02:48:43 matt 101 | ** clearly labelled structure members 102 | ** 103 | ** Revision 1.1 2000/07/06 01:01:56 matt 104 | ** initial revision 105 | ** 106 | */ 107 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map079.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map78.c 21 | ** 22 | ** mapper 78 interface 23 | ** $Id: map079.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 79: NINA-03/06 */ 30 | static void map79_write(uint32 address, uint8 value) 31 | { 32 | if ((address & 0x5100) == 0x4100) 33 | { 34 | mmc_bankrom(32, 0x8000, (value >> 3) & 1); 35 | mmc_bankvrom(8, 0x0000, value & 7); 36 | } 37 | } 38 | 39 | static void map79_init(void) 40 | { 41 | mmc_bankrom(32, 0x8000, 0); 42 | mmc_bankvrom(8, 0x0000, 0); 43 | } 44 | 45 | static map_memwrite map79_memwrite[] = {{0x4100, 0x5FFF, map79_write}, /* ????? incorrect range ??? */ 46 | {-1, -1, NULL}}; 47 | 48 | mapintf_t map79_intf = { 49 | 79, /* mapper number */ 50 | "NINA-03/06", /* mapper name */ 51 | map79_init, /* init routine */ 52 | NULL, /* vblank callback */ 53 | NULL, /* hblank callback */ 54 | NULL, /* get state (snss) */ 55 | NULL, /* set state (snss) */ 56 | NULL, /* memory read structure */ 57 | map79_memwrite, /* memory write structure */ 58 | NULL /* external sound device */ 59 | }; 60 | 61 | /* 62 | ** $Log: map079.c,v $ 63 | ** Revision 1.2 2001/04/27 14:37:11 neil 64 | ** wheeee 65 | ** 66 | ** Revision 1.1 2001/04/27 12:54:40 neil 67 | ** blah 68 | ** 69 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 70 | ** initial 71 | ** 72 | ** Revision 1.1 2000/10/24 12:19:33 matt 73 | ** changed directory structure 74 | ** 75 | ** Revision 1.4 2000/10/22 19:17:47 matt 76 | ** mapper cleanups galore 77 | ** 78 | ** Revision 1.3 2000/10/21 19:33:38 matt 79 | ** many more cleanups 80 | ** 81 | ** Revision 1.2 2000/07/06 02:48:43 matt 82 | ** clearly labelled structure members 83 | ** 84 | ** Revision 1.1 2000/07/06 01:01:56 matt 85 | ** initial revision 86 | ** 87 | */ 88 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map087.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map087.c 21 | ** 22 | ** Mapper #87 (16K VROM switch) 23 | ** Implementation by Firebug 24 | ** $Id: map087.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 25 | ** 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | /******************************************/ 35 | /* Mapper #87 write handler ($6000-$7FFF) */ 36 | /******************************************/ 37 | static void map87_write(uint32 address, uint8 value) 38 | { 39 | /* Within range, address written to is irrelevant */ 40 | UNUSED(address); 41 | 42 | /* Very simple: 8K CHR page is selected by D1 */ 43 | if (value & 0x02) 44 | mmc_bankvrom(8, 0x0000, 0x01); 45 | else 46 | mmc_bankvrom(8, 0x0000, 0x00); 47 | 48 | /* Done */ 49 | return; 50 | } 51 | 52 | static map_memwrite map87_memwrite[] = {{0x6000, 0x7FFF, map87_write}, {-1, -1, NULL}}; 53 | 54 | mapintf_t map87_intf = { 55 | 87, /* Mapper number */ 56 | "16K VROM switch", /* Mapper name */ 57 | NULL, /* Initialization routine */ 58 | NULL, /* VBlank callback */ 59 | NULL, /* HBlank callback */ 60 | NULL, /* Get state (SNSS) */ 61 | NULL, /* Set state (SNSS) */ 62 | NULL, /* Memory read structure */ 63 | map87_memwrite, /* Memory write structure */ 64 | NULL /* External sound device */ 65 | }; 66 | 67 | /* 68 | ** $Log: map087.c,v $ 69 | ** Revision 1.2 2001/04/27 14:37:11 neil 70 | ** wheeee 71 | ** 72 | ** Revision 1.1 2001/04/27 12:54:40 neil 73 | ** blah 74 | ** 75 | ** Revision 1.1 2001/04/27 10:57:41 neil 76 | ** wheee 77 | ** 78 | ** Revision 1.1 2000/12/30 06:34:44 firebug 79 | ** Initial revision 80 | ** 81 | ** 82 | */ 83 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map093.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map93.c 21 | ** 22 | ** mapper 93 interface 23 | ** $Id: map093.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static void map93_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | /* ($8000-$FFFF) D7-D4 = switch $8000-$BFFF D0: mirror */ 35 | mmc_bankrom(16, 0x8000, value >> 4); 36 | 37 | if (value & 1) 38 | ppu_mirror(0, 1, 0, 1); /* vert */ 39 | else 40 | ppu_mirror(0, 0, 1, 1); /* horiz */ 41 | } 42 | 43 | static map_memwrite map93_memwrite[] = {{0x8000, 0xFFFF, map93_write}, {-1, -1, NULL}}; 44 | 45 | mapintf_t map93_intf = { 46 | 93, /* mapper number */ 47 | "Mapper 93", /* mapper name */ 48 | NULL, /* init routine */ 49 | NULL, /* vblank callback */ 50 | NULL, /* hblank callback */ 51 | NULL, /* get state (snss) */ 52 | NULL, /* set state (snss) */ 53 | NULL, /* memory read structure */ 54 | map93_memwrite, /* memory write structure */ 55 | NULL /* external sound device */ 56 | }; 57 | 58 | /* 59 | ** $Log: map093.c,v $ 60 | ** Revision 1.2 2001/04/27 14:37:11 neil 61 | ** wheeee 62 | ** 63 | ** Revision 1.1 2001/04/27 12:54:40 neil 64 | ** blah 65 | ** 66 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 67 | ** initial 68 | ** 69 | ** Revision 1.1 2000/12/11 12:33:48 matt 70 | ** initial revision 71 | ** 72 | */ 73 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map094.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map94.c 21 | ** 22 | ** mapper 94 interface 23 | ** $Id: map094.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 94: Senjou no Ookami */ 30 | static void map94_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | /* ($8000-$FFFF) D7-D2 = switch $8000-$BFFF */ 35 | mmc_bankrom(16, 0x8000, value >> 2); 36 | } 37 | 38 | static map_memwrite map94_memwrite[] = {{0x8000, 0xFFFF, map94_write}, {-1, -1, NULL}}; 39 | 40 | mapintf_t map94_intf = { 41 | 94, /* mapper number */ 42 | "Mapper 94", /* mapper name */ 43 | NULL, /* init routine */ 44 | NULL, /* vblank callback */ 45 | NULL, /* hblank callback */ 46 | NULL, /* get state (snss) */ 47 | NULL, /* set state (snss) */ 48 | NULL, /* memory read structure */ 49 | map94_memwrite, /* memory write structure */ 50 | NULL /* external sound device */ 51 | }; 52 | 53 | /* 54 | ** $Log: map094.c,v $ 55 | ** Revision 1.2 2001/04/27 14:37:11 neil 56 | ** wheeee 57 | ** 58 | ** Revision 1.1 2001/04/27 12:54:40 neil 59 | ** blah 60 | ** 61 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 62 | ** initial 63 | ** 64 | ** Revision 1.1 2000/10/24 12:19:33 matt 65 | ** changed directory structure 66 | ** 67 | ** Revision 1.5 2000/10/22 19:17:47 matt 68 | ** mapper cleanups galore 69 | ** 70 | ** Revision 1.4 2000/10/21 19:33:38 matt 71 | ** many more cleanups 72 | ** 73 | ** Revision 1.3 2000/08/16 02:50:11 matt 74 | ** random mapper cleanups 75 | ** 76 | ** Revision 1.2 2000/07/06 02:48:43 matt 77 | ** clearly labelled structure members 78 | ** 79 | ** Revision 1.1 2000/07/06 01:01:56 matt 80 | ** initial revision 81 | ** 82 | */ 83 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map099.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map99.c 21 | ** 22 | ** mapper 99 interface 23 | ** $Id: map099.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* Switch VROM for VS games */ 31 | static void map99_vromswitch(uint8 value) 32 | { 33 | int bank = (value & 0x04) >> 2; 34 | mmc_bankvrom(8, 0x0000, bank); 35 | } 36 | 37 | /* mapper 99: VS. System */ 38 | static void map99_init(void) 39 | { 40 | ppu_mirror(0, 1, 2, 3); 41 | ppu_setvromswitch(map99_vromswitch); 42 | } 43 | 44 | mapintf_t map99_intf = { 45 | 99, /* mapper number */ 46 | "VS. System", /* mapper name */ 47 | map99_init, /* init routine */ 48 | NULL, /* vblank callback */ 49 | NULL, /* hblank callback */ 50 | NULL, /* get state (snss) */ 51 | NULL, /* set state (snss) */ 52 | NULL, /* memory read structure */ 53 | NULL, /* memory write structure */ 54 | NULL /* external sound device */ 55 | }; 56 | 57 | /* 58 | ** $Log: map099.c,v $ 59 | ** Revision 1.2 2001/04/27 14:37:11 neil 60 | ** wheeee 61 | ** 62 | ** Revision 1.1 2001/04/27 12:54:40 neil 63 | ** blah 64 | ** 65 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 66 | ** initial 67 | ** 68 | ** Revision 1.1 2000/10/24 12:19:33 matt 69 | ** changed directory structure 70 | ** 71 | ** Revision 1.6 2000/10/22 19:17:47 matt 72 | ** mapper cleanups galore 73 | ** 74 | ** Revision 1.5 2000/10/21 19:33:38 matt 75 | ** many more cleanups 76 | ** 77 | ** Revision 1.4 2000/10/10 13:58:17 matt 78 | ** stroustrup squeezing his way in the door 79 | ** 80 | ** Revision 1.3 2000/07/10 05:29:03 matt 81 | ** cleaned up some mirroring issues 82 | ** 83 | ** Revision 1.2 2000/07/06 02:48:43 matt 84 | ** clearly labelled structure members 85 | ** 86 | ** Revision 1.1 2000/07/05 05:05:18 matt 87 | ** initial revision 88 | ** 89 | */ 90 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map229.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map229.c 21 | ** 22 | ** Mapper #229 (31 in 1) 23 | ** Implementation by Firebug 24 | ** Mapper information courtesy of Mark Knibbs 25 | ** $Id: map229.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 26 | ** 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /************************/ 36 | /* Mapper #229: 31 in 1 */ 37 | /************************/ 38 | static void map229_init(void) 39 | { 40 | /* On reset, PRG is set to first 32K and CHR to first 8K */ 41 | mmc_bankrom(32, 0x8000, 0x00); 42 | mmc_bankvrom(8, 0x0000, 0x00); 43 | 44 | /* Done */ 45 | return; 46 | } 47 | 48 | /*******************************************/ 49 | /* Mapper #229 write handler ($8000-$FFFF) */ 50 | /*******************************************/ 51 | static void map229_write(uint32 address, uint8 value) 52 | { 53 | /* Value written is irrelevant */ 54 | UNUSED(value); 55 | 56 | /* A4-A0 sets 8K CHR page */ 57 | mmc_bankvrom(8, 0x0000, (uint8)(address & 0x1F)); 58 | 59 | /* If A4-A1 are all low then select the first 32K, */ 60 | /* otherwise select a 16K bank at both $8000 and $C000 */ 61 | if ((address & 0x1E) == 0x00) 62 | { 63 | mmc_bankrom(32, 0x8000, 0x00); 64 | } 65 | else 66 | { 67 | mmc_bankrom(16, 0x8000, (uint8)(address & 0x1F)); 68 | mmc_bankrom(16, 0xC000, (uint8)(address & 0x1F)); 69 | } 70 | 71 | /* A5: mirroring (low = vertical, high = horizontal) */ 72 | if (address & 0x20) 73 | ppu_mirror(0, 0, 1, 1); 74 | else 75 | ppu_mirror(0, 1, 0, 1); 76 | 77 | /* Done */ 78 | return; 79 | } 80 | 81 | static map_memwrite map229_memwrite[] = {{0x8000, 0xFFFF, map229_write}, {-1, -1, NULL}}; 82 | 83 | mapintf_t map229_intf = { 84 | 229, /* Mapper number */ 85 | "31 in 1 (bootleg)", /* Mapper name */ 86 | map229_init, /* Initialization routine */ 87 | NULL, /* VBlank callback */ 88 | NULL, /* HBlank callback */ 89 | NULL, /* Get state (SNSS) */ 90 | NULL, /* Set state (SNSS) */ 91 | NULL, /* Memory read structure */ 92 | map229_memwrite, /* Memory write structure */ 93 | NULL /* External sound device */ 94 | }; 95 | 96 | /* 97 | ** $Log: map229.c,v $ 98 | ** Revision 1.2 2001/04/27 14:37:11 neil 99 | ** wheeee 100 | ** 101 | ** Revision 1.1 2001/04/27 12:54:40 neil 102 | ** blah 103 | ** 104 | ** Revision 1.1 2001/04/27 10:57:41 neil 105 | ** wheee 106 | ** 107 | ** Revision 1.1 2000/12/30 06:34:31 firebug 108 | ** Initial revision 109 | ** 110 | ** 111 | */ 112 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/mappers/map231.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map231.c 21 | ** 22 | ** mapper 231 interface 23 | ** $Id: map231.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 231: NINA-07, used in Wally Bear and the NO! Gang */ 30 | 31 | static void map231_init(void) { mmc_bankrom(32, 0x8000, MMC_LASTBANK); } 32 | 33 | static void map231_write(uint32 address, uint8 value) 34 | { 35 | int bank, vbank; 36 | UNUSED(address); 37 | 38 | bank = ((value & 0x80) >> 5) | (value & 0x03); 39 | vbank = (value >> 4) & 0x07; 40 | 41 | mmc_bankrom(32, 0x8000, bank); 42 | mmc_bankvrom(8, 0x0000, vbank); 43 | } 44 | 45 | static map_memwrite map231_memwrite[] = {{0x8000, 0xFFFF, map231_write}, {-1, -1, NULL}}; 46 | 47 | mapintf_t map231_intf = { 48 | 231, /* mapper number */ 49 | "NINA-07", /* mapper name */ 50 | map231_init, /* init routine */ 51 | NULL, /* vblank callback */ 52 | NULL, /* hblank callback */ 53 | NULL, /* get state (snss) */ 54 | NULL, /* set state (snss) */ 55 | NULL, /* memory read structure */ 56 | map231_memwrite, /* memory write structure */ 57 | NULL /* external sound device */ 58 | }; 59 | 60 | /* 61 | ** $Log: map231.c,v $ 62 | ** Revision 1.2 2001/04/27 14:37:11 neil 63 | ** wheeee 64 | ** 65 | ** Revision 1.1 2001/04/27 12:54:40 neil 66 | ** blah 67 | ** 68 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 69 | ** initial 70 | ** 71 | ** Revision 1.1 2000/10/24 12:19:33 matt 72 | ** changed directory structure 73 | ** 74 | ** Revision 1.4 2000/10/22 19:17:46 matt 75 | ** mapper cleanups galore 76 | ** 77 | ** Revision 1.3 2000/10/21 19:33:38 matt 78 | ** many more cleanups 79 | ** 80 | ** Revision 1.2 2000/08/16 02:50:11 matt 81 | ** random mapper cleanups 82 | ** 83 | ** Revision 1.1 2000/07/11 03:14:18 melanson 84 | ** Initial commit for mappers 16, 34, and 231 85 | ** 86 | ** 87 | */ 88 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/memguard.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** memguard.h 21 | ** 22 | ** memory allocation wrapper routines 23 | ** $Id: memguard.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _MEMGUARD_H_ 27 | #define _MEMGUARD_H_ 28 | 29 | #ifdef strdup 30 | #undef strdup 31 | #endif 32 | 33 | #ifdef NOFRENDO_DEBUG 34 | 35 | #define malloc(s) _my_malloc((s), __FILE__, __LINE__) 36 | #define free(d) _my_free((void**)&(d), __FILE__, __LINE__) 37 | #define strdup(s) _my_strdup((s), __FILE__, __LINE__) 38 | 39 | extern void* _my_malloc(int size, char* file, int line); 40 | extern void _my_free(void** data, char* file, int line); 41 | extern char* _my_strdup(const char* string, char* file, int line); 42 | 43 | #else /* !NORFRENDO_DEBUG */ 44 | 45 | // /* Non-debugging versions of calls */ 46 | // #define malloc(s) _my_malloc((s)) 47 | // #define free(d) _my_free((void **) &(d)) 48 | // #define strdup(s) _my_strdup((s)) 49 | 50 | extern void* _my_malloc(int size); 51 | extern void _my_free(void** data); 52 | extern char* _my_strdup(const char* string); 53 | 54 | #endif /* !NOFRENDO_DEBUG */ 55 | 56 | extern void mem_cleanup(void); 57 | extern void mem_checkblocks(void); 58 | extern void mem_checkleaks(void); 59 | 60 | extern bool mem_debug; 61 | 62 | #endif /* _MEMGUARD_H_ */ 63 | 64 | /* 65 | ** $Log: memguard.h,v $ 66 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 67 | ** initial 68 | ** 69 | ** Revision 1.11 2000/10/28 03:55:46 neil 70 | ** strdup redefined, previous definition here 71 | ** 72 | ** Revision 1.10 2000/10/25 13:41:29 matt 73 | ** added strdup 74 | ** 75 | ** Revision 1.9 2000/10/10 13:58:13 matt 76 | ** stroustrup squeezing his way in the door 77 | ** 78 | ** Revision 1.8 2000/07/31 04:28:46 matt 79 | ** one million cleanups 80 | ** 81 | ** Revision 1.7 2000/07/17 01:52:27 matt 82 | ** made sure last line of all source files is a newline 83 | ** 84 | ** Revision 1.6 2000/07/06 17:20:52 matt 85 | ** block manager space itself wasn't being freed - d'oh! 86 | ** 87 | ** Revision 1.5 2000/06/26 04:54:48 matt 88 | ** simplified and made more robust 89 | ** 90 | ** Revision 1.4 2000/06/09 15:12:25 matt 91 | ** initial revision 92 | ** 93 | */ 94 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nes/mmclist.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** mmclist.c 21 | ** 22 | ** list of all mapper interfaces 23 | ** $Id: mmclist.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper interfaces */ 30 | extern mapintf_t map0_intf; 31 | extern mapintf_t map1_intf; 32 | extern mapintf_t map2_intf; 33 | extern mapintf_t map3_intf; 34 | extern mapintf_t map4_intf; 35 | extern mapintf_t map5_intf; 36 | extern mapintf_t map7_intf; 37 | extern mapintf_t map8_intf; 38 | extern mapintf_t map9_intf; 39 | extern mapintf_t map10_intf; 40 | extern mapintf_t map11_intf; 41 | extern mapintf_t map15_intf; 42 | extern mapintf_t map16_intf; 43 | extern mapintf_t map18_intf; 44 | extern mapintf_t map19_intf; 45 | extern mapintf_t map21_intf; 46 | extern mapintf_t map22_intf; 47 | extern mapintf_t map23_intf; 48 | extern mapintf_t map24_intf; 49 | extern mapintf_t map25_intf; 50 | extern mapintf_t map32_intf; 51 | extern mapintf_t map33_intf; 52 | extern mapintf_t map34_intf; 53 | extern mapintf_t map40_intf; 54 | extern mapintf_t map64_intf; 55 | extern mapintf_t map65_intf; 56 | extern mapintf_t map66_intf; 57 | extern mapintf_t map70_intf; 58 | extern mapintf_t map75_intf; 59 | extern mapintf_t map78_intf; 60 | extern mapintf_t map79_intf; 61 | extern mapintf_t map85_intf; 62 | extern mapintf_t map94_intf; 63 | extern mapintf_t map99_intf; 64 | extern mapintf_t map231_intf; 65 | 66 | /* implemented mapper interfaces */ 67 | const mapintf_t* mappers[] = { 68 | &map0_intf, &map1_intf, &map2_intf, &map3_intf, &map4_intf, &map5_intf, &map7_intf, &map8_intf, &map9_intf, 69 | &map10_intf, &map11_intf, &map15_intf, &map16_intf, &map18_intf, &map19_intf, &map21_intf, &map22_intf, &map23_intf, 70 | &map24_intf, &map25_intf, &map32_intf, &map33_intf, &map34_intf, &map40_intf, &map64_intf, &map65_intf, &map66_intf, 71 | &map70_intf, &map75_intf, &map78_intf, &map79_intf, &map85_intf, &map94_intf, &map99_intf, &map231_intf, NULL}; 72 | 73 | /* 74 | ** $Log: mmclist.c,v $ 75 | ** Revision 1.2 2001/04/27 14:37:11 neil 76 | ** wheeee 77 | ** 78 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 79 | ** initial 80 | ** 81 | ** Revision 1.1 2000/10/24 12:20:28 matt 82 | ** changed directory structure 83 | ** 84 | ** Revision 1.2 2000/10/10 13:05:30 matt 85 | ** Mr. Clean makes a guest appearance 86 | ** 87 | ** Revision 1.1 2000/07/31 04:27:39 matt 88 | ** initial revision 89 | ** 90 | */ 91 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nes/mmclist.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** mmclist.h 21 | ** 22 | ** list of all mapper interfaces 23 | ** $Id: mmclist.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _MMCLIST_H_ 27 | #define _MMCLIST_H_ 28 | 29 | #include 30 | 31 | extern mapintf_t* mappers[]; 32 | 33 | #endif /* !_MMCLIST_H_ */ 34 | 35 | /* 36 | ** $Log: mmclist.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 41 | ** initial 42 | ** 43 | ** Revision 1.1 2000/10/24 12:20:28 matt 44 | ** changed directory structure 45 | ** 46 | ** Revision 1.1 2000/07/31 04:27:40 matt 47 | ** initial revision 48 | ** 49 | */ 50 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nes/nes_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nes_pal.h 21 | ** 22 | ** NES palette definition 23 | ** $Id: nes_pal.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _NESPAL_H_ 27 | #define _NESPAL_H_ 28 | 29 | extern rgb_t nes_palette[]; 30 | extern rgb_t shady_palette[]; 31 | 32 | extern void pal_generate(void); 33 | 34 | /* TODO: these are temporary hacks */ 35 | extern void pal_dechue(void); 36 | extern void pal_inchue(void); 37 | extern void pal_dectint(void); 38 | extern void pal_inctint(void); 39 | 40 | #endif /* _NESPAL_H_ */ 41 | 42 | /* 43 | ** $Log: nes_pal.h,v $ 44 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 45 | ** initial 46 | ** 47 | ** Revision 1.1 2000/10/24 12:20:28 matt 48 | ** changed directory structure 49 | ** 50 | ** Revision 1.8 2000/07/31 04:27:59 matt 51 | ** one million cleanups 52 | ** 53 | ** Revision 1.7 2000/07/21 04:20:35 matt 54 | ** added some nasty externs 55 | ** 56 | ** Revision 1.6 2000/07/10 13:49:32 matt 57 | ** renamed my palette and extern'ed it 58 | ** 59 | ** Revision 1.5 2000/07/05 17:14:34 neil 60 | ** Linux: Act Two, Scene One 61 | ** 62 | ** Revision 1.4 2000/06/09 15:12:26 matt 63 | ** initial revision 64 | ** 65 | */ 66 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nes/nes_rom.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nes_rom.h 21 | ** 22 | ** NES ROM loading/saving related defines / prototypes 23 | ** $Id: nes_rom.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _NES_ROM_H_ 27 | #define _NES_ROM_H_ 28 | 29 | #include 30 | #include 31 | 32 | typedef enum 33 | { 34 | MIRROR_HORIZ = 0, 35 | MIRROR_VERT = 1 36 | } mirror_t; 37 | 38 | #define ROM_FLAG_BATTERY 0x01 39 | #define ROM_FLAG_TRAINER 0x02 40 | #define ROM_FLAG_FOURSCREEN 0x04 41 | #define ROM_FLAG_VERSUS 0x08 42 | 43 | typedef struct rominfo_s 44 | { 45 | /* pointers to ROM and VROM */ 46 | uint8 *rom, *vrom; 47 | 48 | /* pointers to SRAM and VRAM */ 49 | uint8 *sram, *vram; 50 | 51 | /* number of banks */ 52 | int rom_banks, vrom_banks; 53 | int sram_banks, vram_banks; 54 | 55 | int mapper_number; 56 | mirror_t mirror; 57 | 58 | uint8 flags; 59 | 60 | char filename[PATH_MAX + 1]; 61 | } rominfo_t; 62 | 63 | extern int rom_checkmagic(const char* filename); 64 | extern rominfo_t* rom_load(const char* filename); 65 | extern void rom_free(rominfo_t** rominfo); 66 | extern char* rom_getinfo(rominfo_t* rominfo); 67 | 68 | #endif /* _NES_ROM_H_ */ 69 | 70 | /* 71 | ** $Log: nes_rom.h,v $ 72 | ** Revision 1.2 2001/04/27 14:37:11 neil 73 | ** wheeee 74 | ** 75 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 76 | ** initial 77 | ** 78 | ** Revision 1.2 2000/10/25 01:23:08 matt 79 | ** basic system autodetection 80 | ** 81 | ** Revision 1.1 2000/10/24 12:20:28 matt 82 | ** changed directory structure 83 | ** 84 | ** Revision 1.11 2000/10/22 15:01:29 matt 85 | ** irrelevant mirroring modes removed 86 | ** 87 | ** Revision 1.10 2000/10/17 03:22:38 matt 88 | ** cleaning up rom module 89 | ** 90 | ** Revision 1.9 2000/10/10 13:58:13 matt 91 | ** stroustrup squeezing his way in the door 92 | ** 93 | ** Revision 1.8 2000/10/10 13:03:54 matt 94 | ** Mr. Clean makes a guest appearance 95 | ** 96 | ** Revision 1.7 2000/07/25 02:20:58 matt 97 | ** cleanups 98 | ** 99 | ** Revision 1.6 2000/07/19 15:59:39 neil 100 | ** PATH_MAX, strncpy, snprintf, and strncat are our friends 101 | ** 102 | ** Revision 1.5 2000/07/17 01:52:27 matt 103 | ** made sure last line of all source files is a newline 104 | ** 105 | ** Revision 1.4 2000/06/09 15:12:25 matt 106 | ** initial revision 107 | ** 108 | */ 109 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nes/nesinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nesinput.h 21 | ** 22 | ** Platform independent input definitions 23 | ** $Id: nesinput.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _NESINPUT_H_ 27 | #define _NESINPUT_H_ 28 | 29 | /* NES control pad bitmasks */ 30 | #define INP_PAD_A 0x01 31 | #define INP_PAD_B 0x02 32 | #define INP_PAD_SELECT 0x04 33 | #define INP_PAD_START 0x08 34 | #define INP_PAD_UP 0x10 35 | #define INP_PAD_DOWN 0x20 36 | #define INP_PAD_LEFT 0x40 37 | #define INP_PAD_RIGHT 0x80 38 | 39 | #define INP_ZAPPER_HIT 0x00 40 | #define INP_ZAPPER_MISS 0x08 41 | #define INP_ZAPPER_TRIG 0x10 42 | 43 | #define INP_JOYPAD0 0x0001 44 | #define INP_JOYPAD1 0x0002 45 | #define INP_ZAPPER 0x0004 46 | #define INP_POWERPAD 0x0008 47 | #define INP_ARKANOID 0x0010 48 | #define INP_VSDIPSW0 0x0020 49 | #define INP_VSDIPSW1 0x0040 50 | 51 | /* upper byte is what's returned in D4, lower is D3 */ 52 | #define INP_PPAD_1 0x0002 53 | #define INP_PPAD_2 0x0001 54 | #define INP_PPAD_3 0x0200 55 | #define INP_PPAD_4 0x0100 56 | #define INP_PPAD_5 0x0004 57 | #define INP_PPAD_6 0x0010 58 | #define INP_PPAD_7 0x0080 59 | #define INP_PPAD_8 0x0800 60 | #define INP_PPAD_9 0x0008 61 | #define INP_PPAD_10 0x0020 62 | #define INP_PPAD_11 0x0040 63 | #define INP_PPAD_12 0x0400 64 | 65 | enum 66 | { 67 | INP_STATE_BREAK, 68 | INP_STATE_MAKE 69 | }; 70 | 71 | typedef struct nesinput_s 72 | { 73 | int type; 74 | int data; 75 | } nesinput_t; 76 | 77 | #define MAX_CONTROLLERS 32 78 | 79 | extern uint8 input_get(int type); 80 | extern void input_register(nesinput_t* input); 81 | extern void input_event(nesinput_t* input, int state, int value); 82 | extern void input_strobe(void); 83 | 84 | #endif /* _NESINPUT_H_ */ 85 | 86 | /* 87 | ** $Log: nesinput.h,v $ 88 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 89 | ** initial 90 | ** 91 | ** Revision 1.1 2000/10/24 12:20:28 matt 92 | ** changed directory structure 93 | ** 94 | ** Revision 1.6 2000/09/10 23:25:02 matt 95 | ** minor changes 96 | ** 97 | ** Revision 1.5 2000/07/17 01:52:29 matt 98 | ** made sure last line of all source files is a newline 99 | ** 100 | ** Revision 1.4 2000/06/09 15:12:26 matt 101 | ** initial revision 102 | ** 103 | */ 104 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nes/nesstate.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nesstate.h 21 | ** 22 | ** state saving header 23 | ** $Id: nesstate.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _NESSTATE_H_ 27 | #define _NESSTATE_H_ 28 | 29 | #include 30 | 31 | extern void state_setslot(int slot); 32 | // extern int state_load(); 33 | // extern int state_save(); 34 | 35 | void save_sram(); 36 | void load_sram(); 37 | 38 | #endif /* _NESSTATE_H_ */ 39 | 40 | /* 41 | ** $Log: nesstate.h,v $ 42 | ** Revision 1.2 2001/04/27 14:37:11 neil 43 | ** wheeee 44 | ** 45 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 46 | ** initial 47 | ** 48 | ** Revision 1.2 2000/10/25 00:23:16 matt 49 | ** makefiles updated for new directory structure 50 | ** 51 | ** Revision 1.1 2000/10/24 12:20:28 matt 52 | ** changed directory structure 53 | ** 54 | ** Revision 1.4 2000/10/23 17:50:47 matt 55 | ** adding fds support 56 | ** 57 | ** Revision 1.3 2000/07/25 02:21:23 matt 58 | ** changed routine names to reduce confusion with SNSS routines 59 | ** 60 | ** Revision 1.2 2000/07/17 01:52:28 matt 61 | ** made sure last line of all source files is a newline 62 | ** 63 | ** Revision 1.1 2000/06/29 03:08:18 matt 64 | ** initial revision 65 | ** 66 | */ 67 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nofconfig.h: -------------------------------------------------------------------------------- 1 | /* Nofrendo Configuration API 2 | ** 3 | ** This file is in the public domain. 4 | ** 5 | ** $Id: nofconfig.h,v 1.1 2001/04/27 14:37:11 neil Exp $ 6 | */ 7 | 8 | #ifndef _CONFIG_H_ 9 | #define _CONFIG_H_ 10 | 11 | #ifndef CONFIG_FILE 12 | #define CONFIG_FILE "nofrendo.cfg" 13 | #endif 14 | 15 | typedef struct config_s 16 | { 17 | /* open loads from the disk the saved configuration. 18 | ** 19 | ** open must be the first config function called. 20 | ** 21 | ** open returns true on success, false otherwise. 22 | */ 23 | bool (*open)(void); 24 | 25 | /* close saves the current configuration to disk. 26 | ** 27 | ** close must be the last config function called. 28 | */ 29 | void (*close)(void); 30 | 31 | /* read_int loads an integer from the configuration into "value" 32 | ** 33 | ** If the specified "key" does not exist, the "def"ault is returned 34 | */ 35 | int (*read_int)(const char* group, const char* key, int def); 36 | 37 | /* read_string copies a string from the configuration into "value" 38 | ** 39 | ** If the specified "key" does not exist, the "def"ault is returned 40 | */ 41 | const char* (*read_string)(const char* group, const char* key, const char* def); 42 | 43 | void (*write_int)(const char* group, const char* key, int value); 44 | void (*write_string)(const char* group, const char* key, const char* value); 45 | char* filename; 46 | } config_t; 47 | 48 | extern config_t config; 49 | 50 | #endif /* !_CONFIG_H_ */ 51 | 52 | /* 53 | ** $Log: nofconfig.h,v $ 54 | ** Revision 1.1 2001/04/27 14:37:11 neil 55 | ** wheeee 56 | ** 57 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 58 | ** initial 59 | ** 60 | ** Revision 1.5 2000/10/10 13:58:13 matt 61 | ** stroustrup squeezing his way in the door 62 | ** 63 | ** Revision 1.4 2000/07/19 15:58:55 neil 64 | ** config file now configurable (ha) 65 | ** 66 | ** Revision 1.3 2000/07/11 14:59:27 matt 67 | ** minor cosmetics.. =) 68 | ** 69 | ** Revision 1.2 2000/07/11 13:35:38 bsittler 70 | ** Changed the config API, implemented config file "nofrendo.cfg". The 71 | ** GGI drivers use the group [GGI]. Visual= and Mode= keys are understood. 72 | ** 73 | ** Revision 1.1 2000/07/11 07:46:11 neil 74 | ** Initial commit 75 | ** 76 | ** 77 | */ 78 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/nofrendo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nofrendo.h (c) 1998-2000 Matthew Conte (matt@conte.com) 21 | ** (c) 2000 Neil Stevens (multivac@fcmail.com) 22 | ** 23 | ** Note: all architectures should call these functions 24 | ** 25 | ** $Id: nofrendo.h,v 1.2 2001/04/27 11:10:08 neil Exp $ 26 | */ 27 | //#include 28 | /* emulated system includes */ 29 | //#include 30 | 31 | #ifndef _NOFRENDO_H_ 32 | #define _NOFRENDO_H_ 33 | 34 | typedef enum 35 | { 36 | system_unknown, 37 | system_autodetect, 38 | system_nes, 39 | NUM_SUPPORTED_SYSTEMS 40 | } system_t; 41 | 42 | // /* our global machine structure */ 43 | // typedef struct 44 | // { 45 | // char *filename, *nextfilename; 46 | // system_t type, nexttype; 47 | // 48 | // union 49 | // { 50 | // nes_t *nes; 51 | // } machine; 52 | // 53 | // int refresh_rate; 54 | // 55 | // bool quit; 56 | // } console_t; 57 | // 58 | // extern console_t console; 59 | 60 | int nofrendo_main(int argc, char* argv[]); 61 | 62 | extern volatile int nofrendo_ticks; /* system timer ticks */ 63 | 64 | /* osd_main should end with a call to main_loop(). 65 | ** Pass filename = NULL if you want to start with the demo rom 66 | */ 67 | extern int main_loop(const char* filename, system_t type); 68 | 69 | /* These should not be called directly. Use the event interface */ 70 | extern void main_insert(const char* filename, system_t type); 71 | extern void main_eject(void); 72 | extern void main_quit(void); 73 | 74 | #endif /* !_NOFRENDO_H_ */ 75 | 76 | /* 77 | ** $Log: nofrendo.h,v $ 78 | ** Revision 1.2 2001/04/27 11:10:08 neil 79 | ** compile 80 | ** 81 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 82 | ** initial 83 | ** 84 | ** Revision 1.9 2000/11/25 20:26:05 matt 85 | ** removed fds "system" 86 | ** 87 | ** Revision 1.8 2000/11/20 13:22:12 matt 88 | ** standardized timer ISR, added nofrendo_ticks 89 | ** 90 | ** Revision 1.7 2000/11/01 14:15:35 matt 91 | ** multi-system event system, or whatever 92 | ** 93 | ** Revision 1.6 2000/10/25 13:42:02 matt 94 | ** strdup - giddyap! 95 | ** 96 | ** Revision 1.5 2000/10/25 01:23:08 matt 97 | ** basic system autodetection 98 | ** 99 | ** Revision 1.4 2000/10/23 15:52:04 matt 100 | ** better system handling 101 | ** 102 | ** Revision 1.3 2000/07/31 04:28:46 matt 103 | ** one million cleanups 104 | ** 105 | ** Revision 1.2 2000/07/27 01:16:36 matt 106 | ** sorted out the video problems 107 | ** 108 | ** Revision 1.1 2000/07/26 21:36:13 neil 109 | ** Big honkin' change -- see the mailing list 110 | ** 111 | ** 112 | */ 113 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/noftypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** types.h 21 | ** 22 | ** Data type definitions 23 | ** $Id: noftypes.h,v 1.1 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _TYPES_H_ 27 | #define _TYPES_H_ 28 | 29 | /* Define this if running on little-endian (x86) systems */ 30 | #define HOST_LITTLE_ENDIAN 31 | 32 | #ifdef __GNUC__ 33 | #define INLINE static inline 34 | #define ZERO_LENGTH 0 35 | #elif defined(WIN32) 36 | #define INLINE static __inline 37 | #define ZERO_LENGTH 0 38 | #else /* crapintosh? */ 39 | #define INLINE static 40 | #define ZERO_LENGTH 1 41 | #endif 42 | 43 | /* quell stupid compiler warnings */ 44 | #define UNUSED(x) ((x) = (x)) 45 | 46 | typedef signed char int8; 47 | typedef signed short int16; 48 | typedef signed int int32; 49 | typedef unsigned char uint8; 50 | typedef unsigned short uint16; 51 | typedef unsigned int uint32; 52 | 53 | #ifndef __cplusplus 54 | typedef enum 55 | { 56 | false = 0, 57 | true = 1 58 | } bool; 59 | 60 | #ifndef NULL 61 | #define NULL ((void*)0) 62 | #endif 63 | #endif /* !__cplusplus */ 64 | 65 | #include 66 | #include 67 | 68 | #ifdef NOFRENDO_DEBUG 69 | 70 | #define ASSERT(expr) log_assert((int)(expr), __LINE__, __FILE__, NULL) 71 | #define ASSERT_MSG(msg) log_assert(false, __LINE__, __FILE__, (msg)) 72 | 73 | #else /* !NOFRENDO_DEBUG */ 74 | 75 | #define ASSERT(expr) 76 | #define ASSERT_MSG(msg) 77 | 78 | #endif /* !NOFRENDO_DEBUG */ 79 | 80 | #endif /* _TYPES_H_ */ 81 | 82 | /* 83 | ** $Log: noftypes.h,v $ 84 | ** Revision 1.1 2001/04/27 14:37:11 neil 85 | ** wheeee 86 | ** 87 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 88 | ** initial 89 | ** 90 | ** Revision 1.15 2000/11/05 16:37:18 matt 91 | ** rolled rgb.h into bitmap.h 92 | ** 93 | ** Revision 1.14 2000/10/17 03:22:16 matt 94 | ** safe UNUSED 95 | ** 96 | ** Revision 1.13 2000/10/10 13:58:14 matt 97 | ** stroustrup squeezing his way in the door 98 | ** 99 | ** Revision 1.12 2000/10/10 13:03:54 matt 100 | ** Mr. Clean makes a guest appearance 101 | ** 102 | ** Revision 1.11 2000/08/11 01:44:05 matt 103 | ** cosmeses 104 | ** 105 | ** Revision 1.10 2000/07/31 04:28:47 matt 106 | ** one million cleanups 107 | ** 108 | ** Revision 1.9 2000/07/24 04:30:17 matt 109 | ** ASSERTs should have been calling log_shutdown 110 | ** 111 | ** Revision 1.8 2000/07/17 01:52:28 matt 112 | ** made sure last line of all source files is a newline 113 | ** 114 | ** Revision 1.7 2000/07/04 04:46:44 matt 115 | ** moved INLINE define from osd.h 116 | ** 117 | ** Revision 1.6 2000/06/09 15:12:25 matt 118 | ** initial revision 119 | ** 120 | */ 121 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/pcx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** pcx.h 21 | ** 22 | ** PCX format screen-saving routines 23 | ** $Id: pcx.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _PCX_H_ 27 | #define _PCX_H_ 28 | 29 | #include 30 | #include 31 | 32 | /* Got these out of ZSoft's document */ 33 | typedef struct pcxheader_s 34 | { 35 | uint8 Manufacturer __PACKED__; 36 | uint8 Version __PACKED__; 37 | uint8 Encoding __PACKED__; 38 | uint8 BitsPerPixel __PACKED__; 39 | uint16 Xmin __PACKED__; 40 | uint16 Ymin __PACKED__; 41 | uint16 Xmax __PACKED__; 42 | uint16 Ymax __PACKED__; 43 | uint16 HDpi __PACKED__; 44 | uint16 VDpi __PACKED__; 45 | uint8 Colormap[48] __PACKED__; 46 | uint8 Reserved __PACKED__; 47 | uint8 NPlanes __PACKED__; 48 | uint16 BytesPerLine __PACKED__; 49 | uint16 PaletteInfo __PACKED__; 50 | uint16 HscreenSize __PACKED__; 51 | uint16 VscreenSize __PACKED__; 52 | uint8 Filler[54] __PACKED__; 53 | } pcxheader_t; 54 | 55 | extern int pcx_write(char* filename, bitmap_t* bmp, rgb_t* pal); 56 | 57 | #endif /* _PCX_H_ */ 58 | 59 | /* 60 | ** $Log: pcx.h,v $ 61 | ** Revision 1.2 2001/04/27 14:37:11 neil 62 | ** wheeee 63 | ** 64 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 65 | ** initial 66 | ** 67 | ** Revision 1.8 2000/11/05 16:37:18 matt 68 | ** rolled rgb.h into bitmap.h 69 | ** 70 | ** Revision 1.7 2000/07/25 02:21:56 matt 71 | ** had forgotten some includes 72 | ** 73 | ** Revision 1.6 2000/07/17 01:52:27 matt 74 | ** made sure last line of all source files is a newline 75 | ** 76 | ** Revision 1.5 2000/06/26 04:55:13 matt 77 | ** changed routine name, big whoop 78 | ** 79 | ** Revision 1.4 2000/06/09 15:12:25 matt 80 | ** initial revision 81 | ** 82 | */ 83 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/sndhrdw/fds_snd.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** fds_snd.c 21 | ** 22 | ** Famicom Disk System sound emulation 23 | ** $Id: fds_snd.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static int32 fds_incsize = 0; 31 | 32 | /* mix sound channels together */ 33 | static int32 fds_process(void) 34 | { 35 | int32 output; 36 | output = 0; 37 | 38 | return output; 39 | } 40 | 41 | /* write to registers */ 42 | static void fds_write(uint32 address, uint8 value) 43 | { 44 | UNUSED(address); 45 | UNUSED(value); 46 | } 47 | 48 | /* reset state of vrcvi sound channels */ 49 | static void fds_reset(void) 50 | { 51 | apu_t apu; 52 | 53 | apu_getcontext(&apu); 54 | // fds_incsize = apu.cycle_rate; 55 | fds_incsize = (int32)(APU_BASEFREQ * 65536.0 / (float)apu.sample_rate); 56 | } 57 | 58 | static apu_memwrite fds_memwrite[] = {{0x4040, 0x4092, fds_write}, {-1, -1, NULL}}; 59 | 60 | apuext_t fds_ext = {NULL, /* no init */ 61 | NULL, /* no shutdown */ 62 | fds_reset, 63 | fds_process, 64 | NULL, /* no reads */ 65 | fds_memwrite}; 66 | 67 | /* 68 | ** $Log: fds_snd.c,v $ 69 | ** Revision 1.2 2001/04/27 14:37:11 neil 70 | ** wheeee 71 | ** 72 | ** Revision 1.1 2001/04/27 12:54:40 neil 73 | ** blah 74 | ** 75 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 76 | ** initial 77 | ** 78 | ** Revision 1.1 2000/10/24 12:19:59 matt 79 | ** changed directory structure 80 | ** 81 | ** Revision 1.9 2000/10/11 12:13:15 matt 82 | ** quelled warnings 83 | ** 84 | ** Revision 1.8 2000/10/03 11:56:20 matt 85 | ** better support for optional sound ext routines 86 | ** 87 | ** Revision 1.7 2000/09/15 13:38:40 matt 88 | ** changes for optimized apu core 89 | ** 90 | ** Revision 1.6 2000/09/15 04:58:07 matt 91 | ** simplifying and optimizing APU core 92 | ** 93 | ** Revision 1.5 2000/07/30 04:32:59 matt 94 | ** no more apu_getcyclerate hack 95 | ** 96 | ** Revision 1.4 2000/07/17 01:52:30 matt 97 | ** made sure last line of all source files is a newline 98 | ** 99 | ** Revision 1.3 2000/07/03 02:18:53 matt 100 | ** much better external module exporting 101 | ** 102 | ** Revision 1.2 2000/06/20 04:06:16 matt 103 | ** migrated external sound definition to apu module 104 | ** 105 | ** Revision 1.1 2000/06/20 00:06:47 matt 106 | ** initial revision 107 | ** 108 | */ 109 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/sndhrdw/fds_snd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** fds_snd.h 21 | ** 22 | ** Famicom Disk System sound emulation 23 | ** $Id: fds_snd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _FDS_SND_H_ 27 | #define _FDS_SND_H_ 28 | 29 | #include 30 | 31 | extern apuext_t fds_ext; 32 | 33 | #endif /* _VRCVISND_H_ */ 34 | 35 | /* 36 | ** $Log: fds_snd.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1 2001/04/27 12:54:40 neil 41 | ** blah 42 | ** 43 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 44 | ** initial 45 | ** 46 | ** Revision 1.1 2000/10/24 12:19:59 matt 47 | ** changed directory structure 48 | ** 49 | ** Revision 1.3 2000/07/17 01:52:31 matt 50 | ** made sure last line of all source files is a newline 51 | ** 52 | ** Revision 1.2 2000/06/20 04:06:16 matt 53 | ** migrated external sound definition to apu module 54 | ** 55 | ** Revision 1.1 2000/06/20 00:06:47 matt 56 | ** initial revision 57 | ** 58 | */ 59 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/sndhrdw/mmc5_snd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** mmc5_snd.h 21 | ** 22 | ** Nintendo MMC5 sound emulation header 23 | ** $Id: mmc5_snd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _MMC5_SND_H_ 27 | #define _MMC5_SND_H_ 28 | 29 | #include 30 | 31 | extern apuext_t mmc5_ext; 32 | 33 | #endif /* !_MMC5_SND_H_ */ 34 | 35 | /* 36 | ** $Log: mmc5_snd.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1 2001/04/27 12:54:40 neil 41 | ** blah 42 | ** 43 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 44 | ** initial 45 | ** 46 | ** Revision 1.2 2000/11/13 00:57:08 matt 47 | ** doesn't look as nasty now 48 | ** 49 | ** Revision 1.1 2000/10/24 12:19:59 matt 50 | ** changed directory structure 51 | ** 52 | ** Revision 1.6 2000/10/10 13:58:18 matt 53 | ** stroustrup squeezing his way in the door 54 | ** 55 | ** Revision 1.5 2000/09/27 12:26:03 matt 56 | ** changed sound accumulators back to floats 57 | ** 58 | ** Revision 1.4 2000/09/15 13:38:40 matt 59 | ** changes for optimized apu core 60 | ** 61 | ** Revision 1.3 2000/07/17 01:52:31 matt 62 | ** made sure last line of all source files is a newline 63 | ** 64 | ** Revision 1.2 2000/06/20 04:06:16 matt 65 | ** migrated external sound definition to apu module 66 | ** 67 | ** Revision 1.1 2000/06/20 00:06:47 matt 68 | ** initial revision 69 | ** 70 | */ 71 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/sndhrdw/vrcvisnd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** vrcvisnd.h 21 | ** 22 | ** VRCVI (Konami MMC) sound hardware emulation header 23 | ** $Id: vrcvisnd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _VRCVISND_H_ 27 | #define _VRCVISND_H_ 28 | 29 | #include 30 | 31 | extern apuext_t vrcvi_ext; 32 | 33 | #endif /* _VRCVISND_H_ */ 34 | 35 | /* 36 | ** $Log: vrcvisnd.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1 2001/04/27 12:54:40 neil 41 | ** blah 42 | ** 43 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 44 | ** initial 45 | ** 46 | ** Revision 1.1 2000/10/24 12:20:00 matt 47 | ** changed directory structure 48 | ** 49 | ** Revision 1.10 2000/09/27 12:26:03 matt 50 | ** changed sound accumulators back to floats 51 | ** 52 | ** Revision 1.9 2000/09/15 13:38:40 matt 53 | ** changes for optimized apu core 54 | ** 55 | ** Revision 1.8 2000/07/17 01:52:31 matt 56 | ** made sure last line of all source files is a newline 57 | ** 58 | ** Revision 1.7 2000/06/20 04:06:16 matt 59 | ** migrated external sound definition to apu module 60 | ** 61 | ** Revision 1.6 2000/06/20 00:08:58 matt 62 | ** changed to driver based API 63 | ** 64 | ** Revision 1.5 2000/06/09 16:49:02 matt 65 | ** removed all floating point from sound generation 66 | ** 67 | ** Revision 1.4 2000/06/09 15:12:28 matt 68 | ** initial revision 69 | ** 70 | */ 71 | -------------------------------------------------------------------------------- /src/rachel/apps/app_nofrendo/nofrendo/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** version.h 21 | ** 22 | ** Program name / version definitions 23 | ** $Id: version.h,v 1.2 2001/05/05 16:50:49 neil Exp $ 24 | */ 25 | 26 | #ifndef _VERSION_H_ 27 | #define _VERSION_H_ 28 | 29 | #ifdef NSF_PLAYER 30 | #define APP_STRING "Nosefart" 31 | #else 32 | #define APP_STRING "Nofrendo" 33 | #endif /* NSF_PLAYER */ 34 | 35 | #define APP_VERSION "2.0" 36 | 37 | #endif /* _VERSION_H_ */ 38 | 39 | /* 40 | ** $Log: version.h,v $ 41 | ** Revision 1.2 2001/05/05 16:50:49 neil 42 | ** preparing for distribution 43 | ** 44 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 45 | ** initial 46 | ** 47 | ** Revision 1.9 2000/07/31 04:28:47 matt 48 | ** one million cleanups 49 | ** 50 | ** Revision 1.8 2000/07/17 01:52:28 matt 51 | ** made sure last line of all source files is a newline 52 | ** 53 | ** Revision 1.7 2000/07/04 04:46:55 matt 54 | ** updated version number 55 | ** 56 | ** Revision 1.6 2000/06/20 00:03:39 matt 57 | ** updated for 1.91 58 | ** 59 | ** Revision 1.5 2000/06/09 17:01:56 matt 60 | ** changed version to 1.90 61 | ** 62 | ** Revision 1.4 2000/06/09 15:12:25 matt 63 | ** initial revision 64 | ** 65 | */ 66 | -------------------------------------------------------------------------------- /src/rachel/apps/app_raylib_games/app_raylib_games.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_raylibgames.cpp 3 | * @author Forairaaaaa 4 | * @brief Ref: https://www.raylib.com/games.html 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_raylib_games.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | #include "../utils/system/ui/ui.h" 16 | #include "games/games.h" 17 | 18 | using namespace MOONCAKE::APPS; 19 | 20 | void AppRaylibgames::onCreate() { spdlog::info("{} onCreate", getAppName()); } 21 | 22 | void AppRaylibgames::onResume() { spdlog::info("{} onResume", getAppName()); } 23 | 24 | using namespace SYSTEM::UI; 25 | 26 | void AppRaylibgames::onRunning() 27 | { 28 | auto menu = SelectMenu(); 29 | 30 | std::vector items = {"[RAYLIB GAMES]", "Arkanoid", "Snake", "Tetris", "Quit"}; 31 | 32 | auto selected = menu.waitResult(items); 33 | 34 | if (selected == 1) 35 | ARKANOID::main(); 36 | else if (selected == 2) 37 | SNAKE::main(); 38 | else if (selected == 3) 39 | TETRIS::main(); 40 | 41 | destroyApp(); 42 | } 43 | 44 | void AppRaylibgames::onDestroy() { spdlog::info("{} onDestroy", getAppName()); } 45 | -------------------------------------------------------------------------------- /src/rachel/apps/app_raylib_games/app_raylib_games.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_raylibgames.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_raylib_games.hpp" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Raylibgames 18 | * 19 | */ 20 | class AppRaylibgames : public APP_BASE 21 | { 22 | public: 23 | void onCreate() override; 24 | void onResume() override; 25 | void onRunning() override; 26 | void onDestroy() override; 27 | }; 28 | 29 | class AppRaylibgames_Packer : public APP_PACKER_BASE 30 | { 31 | std::string getAppName() override { return "Raylib Games"; } 32 | void* getAppIcon() override { return (void*)image_data_icon_app_raylib_games; } 33 | void* newApp() override { return new AppRaylibgames; } 34 | void deleteApp(void* app) override { delete (AppRaylibgames*)app; } 35 | }; 36 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_raylib_games/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_raylib_games/games/games.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file games.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-13 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | 13 | namespace ARKANOID 14 | { 15 | int main(void); 16 | } 17 | namespace SNAKE 18 | { 19 | int main(void); 20 | } 21 | namespace TETRIS 22 | { 23 | int main(void); 24 | } 25 | -------------------------------------------------------------------------------- /src/rachel/apps/app_raylib_games/raylib/raylib.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file raylib.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-13 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "raylib.h" 12 | 13 | void InitWindow(int w, int h, const char* title) { HAL::LoadLauncherFont24(); } 14 | 15 | void SetTargetFPS(int fps) {} 16 | 17 | bool WindowShouldClose() { return HAL::GetButton(GAMEPAD::BTN_SELECT); } 18 | 19 | void CloseWindow() {} 20 | 21 | int GetScreenWidth() { return HAL::GetCanvas()->width(); } 22 | 23 | void BeginDrawing() {} 24 | 25 | void EndDrawing() { HAL::CanvasUpdate(); } 26 | 27 | void ClearBackground(uint32_t color) { HAL::GetCanvas()->fillScreen(color); } 28 | 29 | void DrawRectangle(int x, int y, int w, int h, uint32_t color) { HAL::GetCanvas()->fillRect(x, y, w, h, color); } 30 | 31 | void DrawCircleV(Vector2 center, float r, uint32_t color) { HAL::GetCanvas()->fillSmoothCircle(center.x, center.y, r, color); } 32 | 33 | void DrawLineV(Vector2 startPos, Vector2 endPos, uint32_t color) 34 | { 35 | HAL::GetCanvas()->drawLine(startPos.x, startPos.y, endPos.x, endPos.y, color); 36 | } 37 | 38 | void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, uint32_t color) 39 | { 40 | HAL::GetCanvas()->drawLine(startPosX, startPosY, endPosX, endPosY, color); 41 | } 42 | 43 | void DrawRectangleV(Vector2 position, Vector2 size, uint32_t color) 44 | { 45 | HAL::GetCanvas()->fillRect(position.x, position.y, size.x, size.y, color); 46 | } 47 | 48 | #include 49 | std::random_device rd; 50 | std::mt19937 gen(rd()); 51 | int GetRandomValue(int min, int max) 52 | { 53 | std::uniform_int_distribution<> dist(min, max); 54 | return dist(gen); 55 | } 56 | 57 | // Check collision between circle and rectangle 58 | // NOTE: Reviewed version to take into account corner limit case 59 | bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) 60 | { 61 | bool collision = false; 62 | 63 | int recCenterX = (int)(rec.x + rec.width / 2.0f); 64 | int recCenterY = (int)(rec.y + rec.height / 2.0f); 65 | 66 | float dx = fabsf(center.x - (float)recCenterX); 67 | float dy = fabsf(center.y - (float)recCenterY); 68 | 69 | if (dx > (rec.width / 2.0f + radius)) 70 | { 71 | return false; 72 | } 73 | if (dy > (rec.height / 2.0f + radius)) 74 | { 75 | return false; 76 | } 77 | 78 | if (dx <= (rec.width / 2.0f)) 79 | { 80 | return true; 81 | } 82 | if (dy <= (rec.height / 2.0f)) 83 | { 84 | return true; 85 | } 86 | 87 | float cornerDistanceSq = 88 | (dx - rec.width / 2.0f) * (dx - rec.width / 2.0f) + (dy - rec.height / 2.0f) * (dy - rec.height / 2.0f); 89 | 90 | collision = (cornerDistanceSq <= (radius * radius)); 91 | 92 | return collision; 93 | } 94 | -------------------------------------------------------------------------------- /src/rachel/apps/app_raylib_games/raylib/raylib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file raylib.h 3 | * @author Forairaaaaa 4 | * @brief Ref: https://www.raylib.com/cheatsheet/cheatsheet.html 5 | * @version 0.1 6 | * @date 2023-11-13 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../../../hal/hal.h" 13 | #include "../../assets/theme/theme.h" 14 | #include "../../utils/system/ui/ui.h" 15 | #include 16 | 17 | // Vector2 type 18 | typedef struct Vector2 19 | { 20 | float x; 21 | float y; 22 | } Vector2; 23 | 24 | // Rectangle type 25 | typedef struct Rectangle 26 | { 27 | float x; 28 | float y; 29 | float width; 30 | float height; 31 | } Rectangle; 32 | 33 | // Some Basic Colors 34 | // NOTE: Custom raylib color palette for amazing visuals on WHITE background 35 | #define LIGHTGRAY 0xC8C8C8 // Light Gray 36 | #define GRAY 0x828282 // Gray 37 | #define DARKGRAY 0x505050 // Dark Gray 38 | #define YELLOW 0xFDF900 // Yellow 39 | #define GOLD 0xFFCB00 // Gold 40 | #define ORANGE 0xFFA100 // Orange 41 | #define PINK 0xFF6DC2 // Pink 42 | #define RED 0xE62937 // Red 43 | #define MAROON 0xBE2137 // Maroon 44 | #define GREEN 0x00E430 // Green 45 | #define LIME 0x009E2F // Lime 46 | #define DARKGREEN 0x00752C // Dark Green 47 | #define SKYBLUE 0x66BFFF // Sky Blue 48 | #define BLUE 0x0079F1 // Blue 49 | #define DARKBLUE 0x0052AC // Dark Blue 50 | #define PURPLE 0xC87AFF // Purple 51 | #define VIOLET 0x873CBE // Violet 52 | #define DARKPURPLE 0x701F7E // Dark Purple 53 | #define BEIGE 0xD3B083 // Beige 54 | #define BROWN 0x7F6A4F // Brown 55 | #define DARKBROWN 0x4C3F2F // Dark Brown 56 | 57 | #define WHITE 0xFFFFFF // White 58 | #define BLACK 0x000000 // Black 59 | // #define BLANK 0x // Blank (Transparent) 60 | #define MAGENTA 0xFF00FF // Magenta 61 | #define RAYWHITE 0xF5F5F5 // My own White (raylib logo) 62 | 63 | void InitWindow(int w, int h, const char* title); 64 | void SetTargetFPS(int fps); 65 | bool WindowShouldClose(); 66 | void CloseWindow(); 67 | int GetScreenWidth(); 68 | bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); 69 | void BeginDrawing(); 70 | void EndDrawing(); 71 | void ClearBackground(uint32_t color); 72 | void DrawRectangle(int x, int y, int w, int h, uint32_t color); 73 | void DrawCircleV(Vector2 center, float r, uint32_t color); 74 | void DrawLineV(Vector2 startPos, Vector2 endPos, uint32_t color); 75 | void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, uint32_t color); 76 | void DrawRectangleV(Vector2 position, Vector2 size, uint32_t color); 77 | int GetRandomValue(int min, int max); 78 | -------------------------------------------------------------------------------- /src/rachel/apps/app_screencast/app_screencast.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_screencast.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * Ref: https://github.com/lovyan03/ESP32_ScreenShotReceiver 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_screencast.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | #include "../utils/system/ui/progress_window/progress_window.h" 16 | 17 | // Not enough ram, enable this arduino wifi shit cause font loading from sd card filed 18 | // push png filed, nofrendo load rom loading failed 19 | #define ENABLE_APP_SCREENCAST 0 20 | 21 | #ifdef ESP_PLATFORM 22 | #if ENABLE_APP_SCREENCAST 23 | #include 24 | #include 25 | #include "screen_shot_receiver/TCPReceiver.h" 26 | #endif 27 | #endif 28 | 29 | using namespace MOONCAKE::APPS; 30 | using namespace SYSTEM::UI; 31 | 32 | void AppScreencast::onCreate() { spdlog::info("{} onCreate", getAppName()); } 33 | 34 | void AppScreencast::onResume() { spdlog::info("{} onResume", getAppName()); } 35 | 36 | #ifdef ESP_PLATFORM 37 | // Not enough ram, linking this arduino wifi shit cause font loading from sd card filed 38 | // push png filed, nofrendo load rom loading failed 39 | void AppScreencast::onRunning() 40 | { 41 | #if ENABLE_APP_SCREENCAST 42 | 43 | // :( 44 | HAL::GetCanvas()->deleteSprite(); 45 | HAL::GetDisplay()->setFont(&fonts::efontCN_24); 46 | 47 | // 接続できるまで10秒待機 48 | spdlog::info("try connect wifi in nvs"); 49 | WiFi.mode(WIFI_MODE_STA); 50 | WiFi.begin(); 51 | for (int i = 0; WiFi.status() != WL_CONNECTED && i < 100; i++) 52 | { 53 | delay(100); 54 | if (HAL::GetButton(GAMEPAD::BTN_SELECT)) 55 | HAL::Reboot(); 56 | 57 | ProgressWindow("尝试连接WiFi..", i, false, false); 58 | } 59 | 60 | HAL::GetDisplay()->fillScreen(THEME_COLOR_DARK); 61 | HAL::GetDisplay()->setTextColor(THEME_COLOR_LIGHT, THEME_COLOR_DARK); 62 | 63 | // 接続できない場合はSmartConfigを起動 64 | // https://itunes.apple.com/app/id1071176700 65 | // https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch 66 | if (WiFi.status() != WL_CONNECTED) 67 | { 68 | spdlog::info("start smart config"); 69 | WiFi.mode(WIFI_MODE_APSTA); 70 | WiFi.beginSmartConfig(); 71 | 72 | HAL::GetDisplay()->drawCenterString("等待SmartConfig配网", 120, 120 - 48); 73 | while (WiFi.status() != WL_CONNECTED) 74 | { 75 | delay(100); 76 | if (HAL::GetButton(GAMEPAD::BTN_SELECT)) 77 | HAL::Reboot(); 78 | } 79 | WiFi.stopSmartConfig(); 80 | WiFi.mode(WIFI_MODE_STA); 81 | } 82 | 83 | HAL::GetDisplay()->fillScreen(THEME_COLOR_DARK); 84 | HAL::GetDisplay()->drawCenterString("已连接", 120, 120 - 48); 85 | String ip = "IP: "; 86 | ip += WiFi.localIP().toString(); 87 | HAL::GetDisplay()->drawCenterString(ip.c_str(), 122, 120 - 12); 88 | 89 | auto recv = new TCPReceiver; 90 | recv->setup(HAL::GetDisplay()); 91 | while (1) 92 | { 93 | recv->loop(); 94 | if (HAL::GetButton(GAMEPAD::BTN_SELECT)) 95 | HAL::Reboot(); 96 | } 97 | delete recv; 98 | 99 | // :( 100 | HAL::Reboot(); 101 | #endif 102 | 103 | destroyApp(); 104 | } 105 | #else 106 | 107 | void AppScreencast::onRunning() { HAL::PopFatalError("懒得抽象了"); } 108 | 109 | #endif 110 | 111 | void AppScreencast::onDestroy() { spdlog::info("{} onDestroy", getAppName()); } 112 | -------------------------------------------------------------------------------- /src/rachel/apps/app_screencast/app_screencast.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_screencast.h 3 | * @author Forairaaaaa 4 | * @brief Ref: https://github.com/lovyan03/ESP32_ScreenShotReceiver 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_screen_cast.hpp" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Screencast 18 | * 19 | */ 20 | class AppScreencast : public APP_BASE 21 | { 22 | public: 23 | void onCreate() override; 24 | void onResume() override; 25 | void onRunning() override; 26 | void onDestroy() override; 27 | }; 28 | 29 | class AppScreencast_Packer : public APP_PACKER_BASE 30 | { 31 | std::string getAppName() override { return "Screen Cast"; } 32 | void* getAppIcon() override { return (void*)image_data_icon_app_screen_cast; } 33 | void* newApp() override { return new AppScreencast; } 34 | void deleteApp(void* app) override { delete (AppScreencast*)app; } 35 | }; 36 | } // namespace MOONCAKE::APPS 37 | -------------------------------------------------------------------------------- /src/rachel/apps/app_screencast/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/app_settings.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_settings.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_settings.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | 16 | using namespace MOONCAKE::APPS; 17 | using namespace SYSTEM::UI; 18 | 19 | void AppSettings::onCreate() 20 | { 21 | spdlog::info("{} onCreate", getAppName()); 22 | _data.select_menu = new SelectMenu; 23 | } 24 | 25 | void AppSettings::onResume() { spdlog::info("{} onResume", getAppName()); } 26 | 27 | void AppSettings::onRunning() 28 | { 29 | // Create menu and load pages 30 | _page_index(); 31 | 32 | // If config changed 33 | if (_data.is_config_changed) 34 | { 35 | std::vector items = {"[SAVE CHANGES?]", "Yes", "No"}; 36 | auto selected_item = _data.select_menu->waitResult(items); 37 | if (selected_item == 1) 38 | HAL::SaveSystemConfig(); 39 | } 40 | 41 | destroyApp(); 42 | } 43 | 44 | void AppSettings::onDestroy() 45 | { 46 | delete _data.select_menu; 47 | spdlog::info("{} onDestroy", getAppName()); 48 | } 49 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/app_settings.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_settings.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "assets/icon_app_settings.hpp" 13 | #include "../../utils/system/ui/ui.h" 14 | 15 | namespace MOONCAKE::APPS 16 | { 17 | /** 18 | * @brief Settings 19 | * 20 | */ 21 | class AppSettings : public APP_BASE 22 | { 23 | private: 24 | struct Data_t 25 | { 26 | bool is_config_changed = false; 27 | SYSTEM::UI::SelectMenu* select_menu = nullptr; 28 | }; 29 | Data_t _data; 30 | void _page_index(); 31 | void _page_power(); 32 | void _page_sound(); 33 | void _page_display(); 34 | void _page_time(); 35 | void _page_about(); 36 | 37 | public: 38 | void onCreate() override; 39 | void onResume() override; 40 | void onRunning() override; 41 | void onDestroy() override; 42 | }; 43 | 44 | class AppSettings_Packer : public APP_PACKER_BASE 45 | { 46 | std::string getAppName() override { return "Settings"; } 47 | void* getAppIcon() override { return (void*)image_data_icon_app_settings; } 48 | void* newApp() override { return new AppSettings; } 49 | void deleteApp(void* app) override { delete (AppSettings*)app; } 50 | }; 51 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/pages/page_about.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file page_about.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "../app_settings.h" 12 | #include "../../../hal/hal.h" 13 | #include "../assets/page_about_png.hpp" 14 | 15 | using namespace MOONCAKE::APPS; 16 | 17 | void AppSettings::_page_about() 18 | { 19 | HAL::GetCanvas()->drawPng(page_about_png, page_about_png_size); 20 | HAL::CanvasUpdate(); 21 | 22 | while (1) 23 | { 24 | if (HAL::GetAnyButton()) 25 | { 26 | while (HAL::GetAnyButton()) 27 | HAL::Delay(50); 28 | break; 29 | } 30 | HAL::Delay(50); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/pages/page_display.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file page_display.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "../app_settings.h" 12 | #include "../../utils/system/ui/ui.h" 13 | #include "../../utils//system/inputs/inputs.h" 14 | #include "../../../hal/hal.h" 15 | #include "spdlog/spdlog.h" 16 | #include 17 | #include 18 | 19 | using namespace MOONCAKE::APPS; 20 | using namespace SYSTEM::UI; 21 | using namespace SYSTEM::INPUTS; 22 | 23 | static void _handle_brightness_config() 24 | { 25 | // 15~255 16/step 26 | int brightness = HAL::GetDisplay()->getBrightness(); 27 | bool is_changed = true; 28 | 29 | Button btn_left(GAMEPAD::BTN_LEFT); 30 | Button btn_right(GAMEPAD::BTN_RIGHT); 31 | Button btn_ok(GAMEPAD::BTN_A); 32 | 33 | std::string title; 34 | while (1) 35 | { 36 | // Render brightness bar 37 | if (is_changed) 38 | { 39 | is_changed = false; 40 | 41 | // Apply change 42 | HAL::GetSystemConfig().brightness = brightness; 43 | HAL::GetDisplay()->setBrightness(HAL::GetSystemConfig().brightness); 44 | 45 | // Render brightness setting bar 46 | title = "Brightness " + std::to_string(brightness); 47 | ProgressWindow(title, brightness * 100 / 255); 48 | HAL::CanvasUpdate(); 49 | } 50 | else 51 | { 52 | HAL::Delay(20); 53 | } 54 | 55 | // Read input 56 | if (btn_left.pressed()) 57 | { 58 | brightness -= 16; 59 | if (brightness < 16) 60 | brightness = 16; 61 | is_changed = true; 62 | } 63 | else if (btn_right.pressed()) 64 | { 65 | brightness += 16; 66 | if (brightness > 255) 67 | brightness = 255; 68 | is_changed = true; 69 | } 70 | else if (btn_ok.released()) 71 | { 72 | break; 73 | } 74 | } 75 | } 76 | 77 | void AppSettings::_page_display() 78 | { 79 | while (1) 80 | { 81 | std::vector items = {"[DISPLAY]"}; 82 | 83 | // Get button sound config 84 | items.push_back("Brightness " + std::to_string(HAL::GetSystemConfig().brightness)); 85 | items.push_back("Back"); 86 | 87 | auto selected = _data.select_menu->waitResult(items); 88 | 89 | // Brightness 90 | if (selected == 1) 91 | { 92 | _handle_brightness_config(); 93 | _data.is_config_changed = true; 94 | } 95 | else 96 | break; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/pages/page_index.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file page_index.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "../app_settings.h" 12 | #include "../../utils/system/ui/ui.h" 13 | 14 | using namespace MOONCAKE::APPS; 15 | using namespace SYSTEM::UI; 16 | 17 | void AppSettings::_page_index() 18 | { 19 | std::vector items = {"[SETTINGS]", "Power", "Display", "Sound", "Time", "About", "Quit"}; 20 | 21 | while (1) 22 | { 23 | auto selected = _data.select_menu->waitResult(items); 24 | 25 | if (selected == 1) 26 | _page_power(); 27 | else if (selected == 2) 28 | _page_display(); 29 | else if (selected == 3) 30 | _page_sound(); 31 | else if (selected == 4) 32 | _page_time(); 33 | else if (selected == 5) 34 | _page_about(); 35 | else 36 | break; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/pages/page_power.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file page_power.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "../app_settings.h" 12 | #include "../../utils/system/ui/ui.h" 13 | #include "../../../hal/hal.h" 14 | 15 | using namespace MOONCAKE::APPS; 16 | using namespace SYSTEM::UI; 17 | 18 | void AppSettings::_page_power() 19 | { 20 | std::vector items = {"[POWER]", "Power Off", "Reboot", "Back"}; 21 | 22 | auto selected = _data.select_menu->waitResult(items); 23 | if (selected == 1) 24 | HAL::PowerOff(); 25 | else if (selected == 2) 26 | HAL::Reboot(); 27 | } 28 | -------------------------------------------------------------------------------- /src/rachel/apps/app_settings/pages/page_sound.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file page_sound.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "../app_settings.h" 12 | #include "../../utils/system/ui/ui.h" 13 | #include "../../../hal/hal.h" 14 | 15 | using namespace MOONCAKE::APPS; 16 | using namespace SYSTEM::UI; 17 | 18 | void AppSettings::_page_sound() 19 | { 20 | while (1) 21 | { 22 | std::vector items = {"[SOUND]"}; 23 | 24 | // Get button sound config 25 | items.push_back(HAL::GetSystemConfig().volume == 0 ? "Button sound OFF" : "Button sound ON"); 26 | items.push_back("Back"); 27 | 28 | auto selected = _data.select_menu->waitResult(items); 29 | 30 | // Button sound 31 | if (selected == 1) 32 | { 33 | HAL::GetSystemConfig().volume = HAL::GetSystemConfig().volume == 0 ? 255 : 0; 34 | _data.is_config_changed = true; 35 | } 36 | else 37 | break; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/rachel/apps/app_template/app_template.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_template.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "app_template.h" 12 | #include "spdlog/spdlog.h" 13 | #include "../../hal/hal.h" 14 | #include "../assets/theme/theme.h" 15 | 16 | using namespace MOONCAKE::APPS; 17 | 18 | // Like setup()... 19 | void AppTemplate::onResume() { spdlog::info("{} onResume", getAppName()); } 20 | 21 | // Like loop()... 22 | void AppTemplate::onRunning() 23 | { 24 | spdlog::info("咩啊"); 25 | HAL::Delay(1000); 26 | 27 | _data.count++; 28 | if (_data.count > 5) 29 | destroyApp(); 30 | } 31 | 32 | void AppTemplate::onDestroy() { spdlog::info("{} onDestroy", getAppName()); } 33 | -------------------------------------------------------------------------------- /src/rachel/apps/app_template/app_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_template.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../assets/icons/icons.h" 13 | 14 | namespace MOONCAKE::APPS 15 | { 16 | /** 17 | * @brief Template 18 | * 19 | */ 20 | class AppTemplate : public APP_BASE 21 | { 22 | private: 23 | struct Data_t 24 | { 25 | unsigned long count = 0; 26 | }; 27 | Data_t _data; 28 | 29 | public: 30 | void onResume() override; 31 | void onRunning() override; 32 | void onDestroy() override; 33 | }; 34 | 35 | class AppTemplate_Packer : public APP_PACKER_BASE 36 | { 37 | std::string getAppName() override { return "Template"; } 38 | void* getAppIcon() override { return (void*)image_data_icon_app_default; } 39 | void* newApp() override { return new AppTemplate; } 40 | void deleteApp(void* app) override { delete (AppTemplate*)app; } 41 | }; 42 | } // namespace MOONCAKE::APPS -------------------------------------------------------------------------------- /src/rachel/apps/app_template/assets/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended store your app's static assets like icons, fonts or any images 3 | -------------------------------------------------------------------------------- /src/rachel/apps/apps.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file apps.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "launcher/launcher.h" 13 | #include "app_template/app_template.h" 14 | #include "app_settings/app_settings.h" 15 | #include "app_screencast/app_screencast.h" 16 | #include "app_music/app_music.h" 17 | #include "app_genshin/app_genshin.h" 18 | #include "app_raylib_games/app_raylib_games.h" 19 | #include "app_ble_gamepad/app_ble_gamepad.h" 20 | #include "app_nofrendo/app_nofrendo.h" 21 | /* Header files locator(Don't remove) */ 22 | 23 | void rachel_app_install_callback(MOONCAKE::Mooncake* mooncake) 24 | { 25 | mooncake->installApp(new MOONCAKE::APPS::AppSettings_Packer); 26 | mooncake->installApp(new MOONCAKE::APPS::AppNofrendo_Packer); 27 | mooncake->installApp(new MOONCAKE::APPS::AppBle_gamepad_Packer); 28 | mooncake->installApp(new MOONCAKE::APPS::AppScreencast_Packer); 29 | mooncake->installApp(new MOONCAKE::APPS::AppRaylibgames_Packer); 30 | mooncake->installApp(new MOONCAKE::APPS::AppMusic_Packer); 31 | mooncake->installApp(new MOONCAKE::APPS::AppGenshin_Packer); 32 | /* Install app locator(Don't remove) */ 33 | } 34 | -------------------------------------------------------------------------------- /src/rachel/apps/assets/fonts/fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fonts.h 3 | * @author Forairaaaaa 4 | * @brief Font convertor: https://rop.nl/truetype2gfx/ 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | -------------------------------------------------------------------------------- /src/rachel/apps/assets/fonts/zpix_24.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forairaaaaa/Rachel/af9b789cff32341a696e6d7a0d7cea113551ac09/src/rachel/apps/assets/fonts/zpix_24.vlw -------------------------------------------------------------------------------- /src/rachel/apps/assets/fonts/zpix_cn_24.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forairaaaaa/Rachel/af9b789cff32341a696e6d7a0d7cea113551ac09/src/rachel/apps/assets/fonts/zpix_cn_24.vlw -------------------------------------------------------------------------------- /src/rachel/apps/assets/icons/icons.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file icons.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "icon_app_default.hpp" 13 | -------------------------------------------------------------------------------- /src/rachel/apps/assets/theme/theme.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file theme.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../fonts/fonts.h" 13 | 14 | #define THEME_COLOR_LIGHT (uint32_t)(0xEFEFEF) 15 | #define THEME_COLOR_DARK (uint32_t)(0x333333) 16 | 17 | #define THEME_APP_ICON_WIDTH 62 18 | #define THEME_APP_ICON_HEIGHT 62 19 | #define THEME_APP_ICON_WIDTH_HALF 31 20 | #define THEME_APP_ICON_HEIGHT_HALF 31 21 | #define THEME_APP_ICON_GAP 16 22 | #define THEME_APP_ICON_MARGIN_TOP 47 23 | 24 | #define THEME_APP_NAME_MARGIN_TOP 173 25 | -------------------------------------------------------------------------------- /src/rachel/apps/launcher/launcher.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file launcher.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "launcher.h" 12 | #include "lgfx/v1/lgfx_fonts.hpp" 13 | #include "spdlog/spdlog.h" 14 | #include "../../hal/hal.h" 15 | #include 16 | #include "../assets/theme/theme.h" 17 | #include "../assets/icons/icons.h" 18 | 19 | using namespace MOONCAKE::APPS; 20 | 21 | void Launcher::onCreate() 22 | { 23 | spdlog::info("{} onCreate", getAppName()); 24 | 25 | // Enable bg running 26 | setAllowBgRunning(true); 27 | // Auto start 28 | startApp(); 29 | 30 | _create_menu(); 31 | } 32 | 33 | void Launcher::onResume() 34 | { 35 | spdlog::info("{} onResume", getAppName()); 36 | 37 | // Load resources 38 | HAL::LoadLauncherFont24(); 39 | // HAL::LoadTextFont24(); 40 | HAL::GetCanvas()->setTextScroll(false); 41 | 42 | _update_clock(true); 43 | } 44 | 45 | void Launcher::onRunning() 46 | { 47 | _update_clock(); 48 | _update_menu(); 49 | } 50 | 51 | void Launcher::onRunningBG() 52 | { 53 | // If only launcher running still 54 | if (mcAppGetFramework()->getAppManager().getCreatedAppNum() == 1) 55 | { 56 | spdlog::info("back to launcher"); 57 | 58 | // Back to business 59 | mcAppGetFramework()->startApp(this); 60 | 61 | // Play app close anim 62 | HAL::LoadLauncherFont24(); 63 | _update_clock(true); 64 | _play_app_anim(false); 65 | } 66 | } 67 | 68 | void Launcher::onPause() 69 | { 70 | // Play app open anim 71 | _play_app_anim(true); 72 | } 73 | 74 | void Launcher::onDestroy() 75 | { 76 | spdlog::info("{} onDestroy", getAppName()); 77 | 78 | _destroy_menu(); 79 | } 80 | 81 | void Launcher::_update_clock(bool updateNow) 82 | { 83 | if ((HAL::Millis() - _data.clock_update_count) > _data.clock_update_interval || updateNow) 84 | { 85 | // Update clock 86 | strftime(_data.string_buffer, 10, "%H:%M", HAL::GetLocalTime()); 87 | _data.clock = _data.string_buffer; 88 | 89 | _data.clock_update_count = HAL::Millis(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/rachel/apps/launcher/launcher.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file launcher.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | #include 14 | #include 15 | #include "../utils/smooth_menu/simple_menu/simple_menu.h" 16 | 17 | namespace MOONCAKE::APPS 18 | { 19 | /** 20 | * @brief Launcher 21 | * 22 | */ 23 | class Launcher : public APP_BASE 24 | { 25 | private: 26 | struct Data_t 27 | { 28 | // Clock 29 | std::string clock; 30 | uint32_t clock_update_count = 0; 31 | const uint32_t clock_update_interval = 1000; 32 | char string_buffer[10]; 33 | 34 | // Menu 35 | SMOOTH_MENU::Simple_Menu* menu = nullptr; 36 | SMOOTH_MENU::SimpleMenuCallback_t* menu_render_cb = nullptr; 37 | uint32_t menu_update_count = 0; 38 | const uint32_t menu_update_interval = 10; 39 | // const uint32_t menu_update_interval = 0; 40 | bool menu_wait_button_released = false; 41 | 42 | // App open and close anim 43 | LVGL::Anim_Path app_anim; 44 | }; 45 | Data_t _data; 46 | void _update_clock(bool updateNow = false); 47 | void _create_menu(); 48 | void _update_menu(); 49 | void _destroy_menu(); 50 | void _play_app_anim(bool open); 51 | 52 | public: 53 | void onCreate() override; 54 | void onResume() override; 55 | void onRunning() override; 56 | void onRunningBG() override; 57 | void onPause() override; 58 | void onDestroy() override; 59 | }; 60 | 61 | class Launcher_Packer : public APP_PACKER_BASE 62 | { 63 | std::string getAppName() override { return "Launcher"; } 64 | void* newApp() override { return new Launcher; } 65 | void deleteApp(void* app) override { delete (Launcher*)app; } 66 | }; 67 | } // namespace MOONCAKE::APPS 68 | -------------------------------------------------------------------------------- /src/rachel/apps/launcher/view/app_anim.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file app_anim.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-05 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "../launcher.h" 12 | #include "menu_render_callback.hpp" 13 | 14 | using namespace MOONCAKE::APPS; 15 | 16 | void Launcher::_play_app_anim(bool open) 17 | { 18 | if (open) 19 | _data.app_anim.setAnim(LVGL::ease_out, THEME_APP_ICON_WIDTH, 320, 360); 20 | else 21 | _data.app_anim.setAnim(LVGL::ease_out, 320, THEME_APP_ICON_WIDTH, 360); 22 | 23 | _data.app_anim.resetTime(HAL::Millis()); 24 | 25 | int anim_value = 0; 26 | int offset = 0; 27 | while (!_data.app_anim.isFinished(HAL::Millis())) 28 | { 29 | if (!open) 30 | _data.menu->update(HAL::Millis()); 31 | 32 | anim_value = _data.app_anim.getValue(HAL::Millis()); 33 | offset = anim_value / 2; 34 | HAL::GetCanvas()->fillSmoothRoundRect(120 - offset, 35 | THEME_APP_ICON_MARGIN_TOP + THEME_APP_ICON_HEIGHT_HALF - offset, 36 | anim_value, 37 | anim_value, 38 | 60, 39 | THEME_COLOR_LIGHT); 40 | 41 | HAL::CanvasUpdate(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/smooth_menu/camera/camera.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file camera.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-06-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../lv_anim/lv_anim.h" 13 | #include "../selector/selector.h" 14 | 15 | namespace SMOOTH_MENU 16 | { 17 | 18 | class Camrea_t : public Selector_t 19 | { 20 | private: 21 | int _width; 22 | int _height; 23 | 24 | public: 25 | Camrea_t() : _width(0), _height(0) {} 26 | ~Camrea_t() = default; 27 | 28 | inline void setSize(int width, int height) 29 | { 30 | _width = width; 31 | _height = height; 32 | } 33 | 34 | /** 35 | * @brief Uptate anim value 36 | * 37 | * @param currentTime 38 | * @param render 39 | */ 40 | void update(uint32_t currentTime, bool renderAtOnce = true); 41 | 42 | /** 43 | * @brief Render selector at once 44 | * 45 | * @param renderMenu 46 | */ 47 | void render(bool renderMenu = true); 48 | 49 | /** 50 | * @brief Get render attribute for rendering 51 | * 52 | * @return const RenderAttribute_t& 53 | */ 54 | const RenderAttribute_t& getRenderAttribute(); 55 | }; 56 | 57 | } // namespace SMOOTH_MENU 58 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/smooth_menu/simple_menu/simple_menu.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file simple_menu.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "simple_menu.h" 12 | 13 | namespace SMOOTH_MENU 14 | { 15 | Simple_Menu::Simple_Menu(int cameraWidth, int cameraHeight) 16 | { 17 | // Create menu 18 | _menu = new Menu_t; 19 | 20 | // Create selector 21 | _selector = new Selector_t; 22 | _selector->setMenu(_menu); 23 | 24 | // Create camera 25 | _camera = new Camrea_t; 26 | _camera->setMenu(_menu); 27 | _camera->setSize(cameraWidth, cameraHeight); 28 | 29 | _render_callback = nullptr; 30 | _first_open = true; 31 | _first_item = 0; 32 | } 33 | 34 | Simple_Menu::~Simple_Menu() 35 | { 36 | delete _menu; 37 | delete _selector; 38 | delete _camera; 39 | } 40 | 41 | void Simple_Menu::setMenuLoopMode(bool loopMode) 42 | { 43 | _selector->setMenuLoopMode(loopMode); 44 | _camera->setMenuLoopMode(loopMode); 45 | } 46 | 47 | void Simple_Menu::update(uint32_t currentTime, bool renderAtOnce) 48 | { 49 | /* Return if empty menu */ 50 | if (!_menu->getItemNum()) 51 | return; 52 | 53 | /* Move the selector to the first item */ 54 | if (_first_open) 55 | { 56 | _first_open = false; 57 | 58 | // Set first item 59 | _selector->reset(currentTime); 60 | _selector->goToItem(_first_item); 61 | _camera->goToItem(_first_item); 62 | 63 | _selector->update(0); 64 | } 65 | 66 | _menu->update(currentTime); 67 | _selector->update(currentTime, false); 68 | _camera->update(currentTime, false); 69 | 70 | // If render at once 71 | if (renderAtOnce) 72 | render(); 73 | } 74 | 75 | void Simple_Menu::render() 76 | { 77 | if (_render_callback == nullptr) 78 | return; 79 | 80 | _render_callback->renderCallback(_menu->getItemList(), _selector->getRenderAttribute(), _camera->getRenderAttribute()); 81 | } 82 | 83 | void Simple_Menu::goLast() 84 | { 85 | _selector->goLast(); 86 | _camera->goLast(); 87 | } 88 | 89 | void Simple_Menu::goNext() 90 | { 91 | _selector->goNext(); 92 | _camera->goNext(); 93 | } 94 | } // namespace SMOOTH_MENU 95 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/smooth_menu/simple_menu/simple_menu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file simple_menu.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../camera/camera.h" 13 | 14 | namespace SMOOTH_MENU 15 | { 16 | class SimpleMenuCallback_t 17 | { 18 | public: 19 | virtual void renderCallback(const std::vector& menuItemList, 20 | const RenderAttribute_t& selector, 21 | const RenderAttribute_t& camera) 22 | { 23 | } 24 | }; 25 | 26 | class Simple_Menu 27 | { 28 | private: 29 | Menu_t* _menu; 30 | Selector_t* _selector; 31 | Camrea_t* _camera; 32 | SimpleMenuCallback_t* _render_callback; 33 | bool _first_open; 34 | int _first_item; 35 | 36 | public: 37 | Simple_Menu(int cameraWidth = 100, int cameraHeight = 100); 38 | ~Simple_Menu(); 39 | 40 | inline Menu_t* getMenu() { return _menu; } 41 | inline Selector_t* getSelector() { return _selector; } 42 | inline Camrea_t* getCamera() { return _camera; } 43 | 44 | /** 45 | * @brief Set menu go back when hit limit 46 | * 47 | * @param loopMode 48 | */ 49 | void setMenuLoopMode(bool loopMode); 50 | 51 | inline void setFirstItem(int item) { _first_item = item; } 52 | 53 | /** 54 | * @brief Set the Render Callback function, for your graphics lib 55 | * 56 | * @param callback 57 | */ 58 | inline void setRenderCallback(SimpleMenuCallback_t* callback) { _render_callback = callback; } 59 | 60 | /** 61 | * @brief Uptate menu 62 | * 63 | * @param currentTime 64 | * @param renderAtOnce 65 | */ 66 | void update(uint32_t currentTime, bool renderAtOnce = true); 67 | 68 | /** 69 | * @brief Go to last item 70 | * 71 | */ 72 | void goLast(); 73 | 74 | /** 75 | * @brief Go to next item 76 | * 77 | */ 78 | void goNext(); 79 | 80 | /** 81 | * @brief Render at once 82 | * 83 | */ 84 | void render(); 85 | }; 86 | } // namespace SMOOTH_MENU 87 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/audio/audio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file audio.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "buzz_music_player/buzz_music_player.h" 13 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/audio/buzz_music_player/buzz_music_player.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file buzz_music_player.h 3 | * @author Forairaaaaa 4 | * @brief Ref: https://github.com/robsoncouto/arduino-songs 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | #include 14 | 15 | namespace SYSTEM::AUDIO 16 | { 17 | struct BuzzMusic_t 18 | { 19 | int tempo = 0; 20 | std::size_t melodySize = 0; 21 | int* melody = nullptr; 22 | 23 | BuzzMusic_t(int tempo, std::size_t melodySize) 24 | { 25 | this->tempo = tempo; 26 | this->melodySize = melodySize; 27 | melody = new int[this->melodySize]; 28 | } 29 | 30 | ~BuzzMusic_t() { delete[] this->melody; } 31 | }; 32 | 33 | class BuzzMusicPlayer 34 | { 35 | public: 36 | static void playRaw(BuzzMusic_t* buzzMusic); 37 | static void playFromSdCard(const char* buzzMusicPath); 38 | }; 39 | } // namespace SYSTEM::AUDIO 40 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/inputs/button/button.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file button.cpp 3 | * @author Forairaaaaa 4 | * @brief Base on https://github.com/madleech/Button, thanks to madleech 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | 12 | /* 13 | Button - a small library for Arduino to handle button debouncing 14 | 15 | MIT licensed. 16 | */ 17 | 18 | #include "button.h" 19 | #include "../../../hal/hal.h" 20 | 21 | using namespace SYSTEM::INPUTS; 22 | 23 | // 24 | // public methods 25 | // 26 | 27 | bool Button::read() 28 | { 29 | // ignore pin changes until after this delay time 30 | if (_ignore_until > HAL::Millis()) 31 | { 32 | // ignore any changes during this period 33 | } 34 | 35 | // pin has changed 36 | else if (HAL::GetButton(_button) != _state) 37 | { 38 | _ignore_until = HAL::Millis() + _delay; 39 | _state = !_state; 40 | _has_changed = true; 41 | } 42 | 43 | return _state; 44 | } 45 | 46 | // has the button been toggled from on -> off, or vice versa 47 | bool Button::toggled() 48 | { 49 | read(); 50 | return has_changed(); 51 | } 52 | 53 | // mostly internal, tells you if a button has changed after calling the read() function 54 | bool Button::has_changed() 55 | { 56 | if (_has_changed) 57 | { 58 | _has_changed = false; 59 | return true; 60 | } 61 | return false; 62 | } 63 | 64 | // has the button gone from off -> on 65 | bool Button::pressed() { return (read() == PRESSED && has_changed()); } 66 | 67 | // has the button gone from on -> off 68 | bool Button::released() { return (read() == RELEASED && has_changed()); } 69 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/inputs/button/button.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file button.h 3 | * @author Forairaaaaa 4 | * @brief Base on https://github.com/madleech/Button, thanks to madleech 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | 12 | /* 13 | Button - a small library for Arduino to handle button debouncing 14 | 15 | MIT licensed. 16 | */ 17 | 18 | #ifndef Button_h 19 | #define Button_h 20 | #include "../../../hal/hal.h" 21 | 22 | namespace SYSTEM::INPUTS 23 | { 24 | /** 25 | * @brief Simple but supper useful button class 26 | * 27 | */ 28 | class Button 29 | { 30 | public: 31 | Button(GAMEPAD::GamePadButton_t button, uint16_t debounce_ms = 50) 32 | : _button(button), _delay(debounce_ms), _state(false), _ignore_until(0), _has_changed(false) 33 | { 34 | } 35 | bool read(); 36 | bool toggled(); 37 | bool pressed(); 38 | bool released(); 39 | bool has_changed(); 40 | 41 | const static bool PRESSED = true; 42 | const static bool RELEASED = false; 43 | 44 | private: 45 | GAMEPAD::GamePadButton_t _button; 46 | uint16_t _delay; 47 | bool _state; 48 | uint32_t _ignore_until; 49 | bool _has_changed; 50 | }; 51 | } // namespace SYSTEM::INPUTS 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/inputs/inputs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file inputs.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-18 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "button/button.h" 13 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/common/data_structs.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file data_structs.hpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-17 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | 14 | namespace SYSTEM::UI 15 | { 16 | struct BasicShape_t 17 | { 18 | int x; 19 | int y; 20 | int width; 21 | int height; 22 | 23 | BasicShape_t(int x = 0, int y = 0, int width = 0, int height = 0) 24 | { 25 | this->x = x; 26 | this->y = y; 27 | this->width = width; 28 | this->height = height; 29 | } 30 | }; 31 | } // namespace SYSTEM::UI 32 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/progress_window/progress_window.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file progress_window.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-17 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "progress_window.h" 12 | #include "../../../../../hal/hal.h" 13 | #include "../common/data_structs.hpp" 14 | #include "../../assets/theme/theme.h" 15 | 16 | void SYSTEM::UI::ProgressWindow(std::string title, uint8_t progress, bool lightMode, bool useCanvas) 17 | { 18 | lgfx::LGFXBase* display = nullptr; 19 | if (useCanvas) 20 | display = HAL::GetCanvas(); 21 | else 22 | display = HAL::GetDisplay(); 23 | 24 | uint32_t color_light = THEME_COLOR_LIGHT; 25 | uint32_t color_dark = THEME_COLOR_DARK; 26 | if (lightMode) 27 | std::swap(color_light, color_dark); 28 | 29 | // Clear screen 30 | display->fillScreen(color_light); 31 | 32 | // Draw title 33 | display->setTextColor(color_dark, color_light); 34 | display->drawCenterString(title.c_str(), display->width() / 2, display->height() / 4); 35 | 36 | // Draw progress bar base 37 | BasicShape_t progress_bar; 38 | progress_bar.width = display->width() * 8 / 10; 39 | progress_bar.height = display->height() / 4; 40 | progress_bar.x = (display->width() - progress_bar.width) / 2; 41 | progress_bar.y = display->height() / 2; 42 | display->fillSmoothRoundRect(progress_bar.x, progress_bar.y, progress_bar.width, progress_bar.height, 10, color_dark); 43 | 44 | // Draw progress bar 45 | if (progress > 100) 46 | progress = 100; 47 | display->fillSmoothRoundRect(progress_bar.x + 4, 48 | progress_bar.y + 4, 49 | (progress_bar.width - 8) * progress / 100, 50 | progress_bar.height - 8, 51 | 10, 52 | color_light); 53 | 54 | // printf("progress x:%d y:%d w:%d h:%d\n", progress_bar.x, progress_bar.y, progress_bar.width, progress_bar.height); 55 | } 56 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/progress_window/progress_window.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file progress_window.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-17 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | 14 | namespace SYSTEM::UI 15 | { 16 | /** 17 | * @brief Render a progress window on the screen, 渲染一个带进度条的页面 18 | * 19 | * @param title Title label on top of the window 20 | * @param progress 0~100 21 | * @param lightMode 22 | */ 23 | void ProgressWindow(std::string title, uint8_t progress, bool lightMode = false, bool useCanvas = true); 24 | } // namespace SYSTEM::UI 25 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/select_menu/components/rcb_align_center.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rcb_align_center.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-11 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "render_callbacks.h" 12 | #include "../../../../../assets/theme/theme.h" 13 | #include "../../../../../../hal/hal.h" 14 | 15 | using namespace SYSTEM::UI; 16 | 17 | void SelectMenuRenderCb_AlignCenter::renderCallback(const std::vector& menuItemList, 18 | const SMOOTH_MENU::RenderAttribute_t& selector, 19 | const SMOOTH_MENU::RenderAttribute_t& camera) 20 | { 21 | // Clear 22 | HAL::GetCanvas()->fillScreen(THEME_COLOR_DARK); 23 | 24 | // Render items 25 | HAL::GetCanvas()->setTextColor(THEME_COLOR_LIGHT, THEME_COLOR_DARK); 26 | HAL::GetCanvas()->setTextSize(1); 27 | HAL::GetCanvas()->setTextDatum(textdatum_t::top_center); 28 | for (int i = 0; i < menuItemList.size(); i++) 29 | { 30 | HAL::GetCanvas()->drawString(menuItemList[i]->tag.c_str(), camera.width / 2, menuItemList[i]->y - camera.y); 31 | } 32 | 33 | // Render selector 34 | HAL::GetCanvas()->setColor(TFT_WHITE); 35 | HAL::GetCanvas()->fillSmoothRoundRectInDifference( 36 | selector.x - camera.x - (selector.width - menuItemList[selector.targetItem]->width) / 2 + 37 | (camera.width / 2 - menuItemList[selector.targetItem]->width / 2) - 10, 38 | selector.y - camera.y + (menuItemList[selector.targetItem]->height - selector.height) / 2, 39 | selector.width, 40 | selector.height, 41 | 6); 42 | } 43 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/select_menu/components/rcb_align_left.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rcb_align_left.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "render_callbacks.h" 12 | #include "../../../../../assets/theme/theme.h" 13 | #include "../../../../../../hal/hal.h" 14 | 15 | using namespace SYSTEM::UI; 16 | 17 | void SelectMenuRenderCb_AlignLeft::renderCallback(const std::vector& menuItemList, 18 | const SMOOTH_MENU::RenderAttribute_t& selector, 19 | const SMOOTH_MENU::RenderAttribute_t& camera) 20 | { 21 | // Clear 22 | HAL::GetCanvas()->fillScreen(THEME_COLOR_DARK); 23 | 24 | // Render items 25 | HAL::GetCanvas()->setTextColor(THEME_COLOR_LIGHT, THEME_COLOR_DARK); 26 | HAL::GetCanvas()->setTextSize(1); 27 | HAL::GetCanvas()->setTextDatum(textdatum_t::top_left); 28 | for (int i = 0; i < menuItemList.size(); i++) 29 | { 30 | HAL::GetCanvas()->drawString(menuItemList[i]->tag.c_str(), menuItemList[i]->x, menuItemList[i]->y - camera.y); 31 | } 32 | 33 | // Render selector 34 | HAL::GetCanvas()->setColor(TFT_WHITE); 35 | HAL::GetCanvas()->fillSmoothRoundRectInDifference(selector.x, 36 | selector.y - camera.y + 37 | (menuItemList[selector.targetItem]->height - selector.height) / 2, 38 | selector.width, 39 | selector.height, 40 | 6); 41 | } 42 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/select_menu/components/rcb_align_right.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rcb_align_right.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-11 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "render_callbacks.h" 12 | #include "../../../../../assets/theme/theme.h" 13 | #include "../../../../../../hal/hal.h" 14 | 15 | using namespace SYSTEM::UI; 16 | 17 | void SelectMenuRenderCb_AlignRight::renderCallback(const std::vector& menuItemList, 18 | const SMOOTH_MENU::RenderAttribute_t& selector, 19 | const SMOOTH_MENU::RenderAttribute_t& camera) 20 | { 21 | // Clear 22 | HAL::GetCanvas()->fillScreen(THEME_COLOR_DARK); 23 | 24 | // Render items 25 | HAL::GetCanvas()->setTextColor(THEME_COLOR_LIGHT, THEME_COLOR_DARK); 26 | HAL::GetCanvas()->setTextSize(1); 27 | HAL::GetCanvas()->setTextDatum(textdatum_t::top_right); 28 | for (int i = 0; i < menuItemList.size(); i++) 29 | { 30 | HAL::GetCanvas()->drawString( 31 | menuItemList[i]->tag.c_str(), menuItemList[i]->x + camera.width - 20, menuItemList[i]->y - camera.y); 32 | } 33 | 34 | // Render selector 35 | HAL::GetCanvas()->setColor(TFT_WHITE); 36 | HAL::GetCanvas()->fillSmoothRoundRectInDifference(selector.x + camera.width - selector.width - 20, 37 | selector.y - camera.y + 38 | (menuItemList[selector.targetItem]->height - selector.height) / 2, 39 | selector.width, 40 | selector.height, 41 | 6); 42 | } 43 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/select_menu/components/render_callbacks.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file render_callbacks.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../../../../smooth_menu/simple_menu/simple_menu.h" 13 | 14 | namespace SYSTEM::UI 15 | { 16 | class SelectMenuRenderCb_AlignLeft : public SMOOTH_MENU::SimpleMenuCallback_t 17 | { 18 | public: 19 | void renderCallback(const std::vector& menuItemList, 20 | const SMOOTH_MENU::RenderAttribute_t& selector, 21 | const SMOOTH_MENU::RenderAttribute_t& camera) override; 22 | }; 23 | 24 | class SelectMenuRenderCb_AlignCenter : public SMOOTH_MENU::SimpleMenuCallback_t 25 | { 26 | public: 27 | void renderCallback(const std::vector& menuItemList, 28 | const SMOOTH_MENU::RenderAttribute_t& selector, 29 | const SMOOTH_MENU::RenderAttribute_t& camera) override; 30 | }; 31 | 32 | class SelectMenuRenderCb_AlignRight : public SMOOTH_MENU::SimpleMenuCallback_t 33 | { 34 | public: 35 | void renderCallback(const std::vector& menuItemList, 36 | const SMOOTH_MENU::RenderAttribute_t& selector, 37 | const SMOOTH_MENU::RenderAttribute_t& camera) override; 38 | }; 39 | } // namespace SYSTEM::UI -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/select_menu/select_menu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file select_menu.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../../../smooth_menu/simple_menu/simple_menu.h" 13 | #include 14 | #include 15 | #include 16 | 17 | namespace SYSTEM::UI 18 | { 19 | /** 20 | * @brief Select menu, 选择菜单 21 | * 22 | */ 23 | class SelectMenu 24 | { 25 | public: 26 | enum ItemsAlignment_t 27 | { 28 | ALIGN_LEFT = 0, 29 | ALIGN_CENTER, 30 | ALIGN_RIGHT, 31 | }; 32 | 33 | struct Config_t 34 | { 35 | int first_item = 1; 36 | uint32_t menu_update_interval = 10; 37 | 38 | LVGL::LV_ANIM_PATH_t menu_open_anim_path = LVGL::ease_out; 39 | int32_t menu_open_anim_time = 400; 40 | 41 | LVGL::LV_ANIM_PATH_t selector_anim_path = LVGL::ease_out; 42 | int32_t selector_anim_time = 100; 43 | bool selector_can_go_loop = true; 44 | 45 | LVGL::LV_ANIM_PATH_t camera_anim_path = LVGL::ease_out; 46 | int32_t camera_anim_time = 400; 47 | 48 | ItemsAlignment_t items_alignment = ALIGN_LEFT; 49 | }; 50 | 51 | private: 52 | struct Data_t 53 | { 54 | SMOOTH_MENU::Simple_Menu* menu = nullptr; 55 | SMOOTH_MENU::SimpleMenuCallback_t* render_cb = nullptr; 56 | uint32_t menu_update_count = 0; 57 | bool menu_wait_button_released = false; 58 | }; 59 | Data_t _data; 60 | Config_t _config; 61 | void _load_config(); 62 | void _create_menu(std::vector& itemList); 63 | void _destroy_menu(); 64 | 65 | public: 66 | inline Config_t getConfig() { return _config; } 67 | inline void setConfig(Config_t cfg) { _config = cfg; } 68 | inline void setItemAlignment(ItemsAlignment_t alignment) { _config.items_alignment = alignment; } 69 | 70 | /** 71 | * @brief Render the menu and blocked untill item selected, 渲染一个菜单并等待选择 72 | * 73 | * @param itemList Items to be select, the first element will be "title", which will not be selected 74 | * @return int selected item index 75 | */ 76 | int waitResult(std::vector& itemList); 77 | inline int waitResult(std::vector& itemList, ItemsAlignment_t alignment) 78 | { 79 | setItemAlignment(alignment); 80 | return waitResult(itemList); 81 | } 82 | }; 83 | } // namespace SYSTEM::UI 84 | -------------------------------------------------------------------------------- /src/rachel/apps/utils/system/ui/ui.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ui.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-10 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "select_menu/select_menu.h" 13 | #include "progress_window/progress_window.h" 14 | -------------------------------------------------------------------------------- /src/rachel/hal/hal.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "hal.h" 13 | 14 | HAL* HAL::_hal = nullptr; 15 | 16 | HAL* HAL::Get() { return _hal; } 17 | 18 | bool HAL::Check() { return _hal != nullptr; } 19 | 20 | bool HAL::Inject(HAL* hal) 21 | { 22 | if (_hal != nullptr) 23 | { 24 | spdlog::error("HAL already exist"); 25 | return false; 26 | } 27 | 28 | if (hal == nullptr) 29 | { 30 | spdlog::error("invalid HAL ptr"); 31 | return false; 32 | } 33 | 34 | hal->init(); 35 | spdlog::info("HAL injected, type: {}", hal->type()); 36 | 37 | _hal = hal; 38 | 39 | return true; 40 | } 41 | 42 | void HAL::Destroy() 43 | { 44 | if (_hal == nullptr) 45 | { 46 | spdlog::error("HAL not exist"); 47 | return; 48 | } 49 | 50 | delete _hal; 51 | _hal = nullptr; 52 | } 53 | 54 | void HAL::renderFpsPanel() 55 | { 56 | static unsigned long time_count = 0; 57 | 58 | _canvas->setTextColor(TFT_WHITE, TFT_BLACK); 59 | _canvas->setTextSize(2); 60 | _canvas->drawNumber(1000 / (millis() - time_count), 0, 0, &fonts::Font0); 61 | 62 | time_count = millis(); 63 | } 64 | 65 | void HAL::popFatalError(std::string msg) 66 | { 67 | static const uint32_t bg_color = 0x0078d7; 68 | 69 | loadTextFont24(); 70 | _canvas->setTextColor(TFT_WHITE, bg_color); 71 | _canvas->fillScreen(bg_color); 72 | 73 | _canvas->setCursor(8, 15); 74 | _canvas->setTextSize(5); 75 | _canvas->printf(":("); 76 | 77 | _canvas->setCursor(0, 155); 78 | _canvas->setTextSize(1); 79 | _canvas->printf(" Fatal Error"); 80 | _canvas->setCursor(0, 185); 81 | _canvas->printf(" %s", msg.c_str()); 82 | 83 | _canvas->pushSprite(0, 0); 84 | 85 | // Press any button to poweroff 86 | while (1) 87 | { 88 | delay(100); 89 | if (getAnyButton()) 90 | reboot(); 91 | } 92 | } 93 | 94 | // Cpp sucks 95 | tm* HAL::getLocalTime() 96 | { 97 | time(&_time_buffer); 98 | return localtime(&_time_buffer); 99 | } 100 | 101 | bool HAL::getAnyButton() 102 | { 103 | for (int i = GAMEPAD::BTN_START; i < GAMEPAD::GAMEPAD_BUTTON_NUM; i++) 104 | { 105 | if (getButton(static_cast(i))) 106 | return true; 107 | } 108 | return false; 109 | } 110 | 111 | void HAL::updateSystemFromConfig() 112 | { 113 | // Brightness 114 | _display->setBrightness(_config.brightness); 115 | 116 | // Volume 117 | setBeepVolume(_config.volume); 118 | } 119 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_fs.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_gamepad.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../hal_rachel.h" 16 | #include "../hal_config.h" 17 | #include 18 | 19 | void HAL_Rachel::_fs_init() 20 | { 21 | spdlog::info("fs init"); 22 | HAL_LOG_INFO("fs init"); 23 | 24 | // File system 25 | if (!LittleFS.begin(true)) 26 | { 27 | spdlog::error("LittleFS init failed!"); 28 | popFatalError("LittleFS init failed"); 29 | } 30 | } 31 | 32 | static const String _system_config_path = "/_sys/cfg.json"; 33 | 34 | void HAL_Rachel::loadSystemConfig() 35 | { 36 | spdlog::info("start loading config from fs"); 37 | 38 | // Check exist 39 | if (!LittleFS.exists(_system_config_path)) 40 | { 41 | spdlog::warn("{} not exist", _system_config_path.c_str()); 42 | saveSystemConfig(); 43 | return; 44 | } 45 | 46 | // Open file 47 | File config_file = LittleFS.open(_system_config_path); 48 | if (!config_file) 49 | popFatalError("打开配置文件失败"); 50 | 51 | // Parse json 52 | DynamicJsonDocument doc(2048); 53 | deserializeJson(doc, config_file); 54 | 55 | // Copy configs 56 | _config.brightness = doc["brightness"]; 57 | _config.volume = doc["volume"]; 58 | 59 | spdlog::info("get config:\nbrightness: {}\nvolume: {}", _config.brightness, _config.volume); 60 | 61 | config_file.close(); 62 | } 63 | 64 | void HAL_Rachel::saveSystemConfig() 65 | { 66 | spdlog::info("start saving config to fs"); 67 | 68 | // Open file 69 | File config_file = LittleFS.open(_system_config_path, FILE_WRITE, true); 70 | if (!config_file) 71 | popFatalError("创建配置文件失败"); 72 | 73 | // Create json 74 | DynamicJsonDocument doc(2048); 75 | doc["brightness"] = _config.brightness; 76 | doc["volume"] = _config.volume; 77 | 78 | // Save file 79 | if (serializeJson(doc, config_file) == 0) 80 | popFatalError("写入配置文件失败"); 81 | 82 | config_file.close(); 83 | } 84 | 85 | void HAL_Rachel::_system_config_init() 86 | { 87 | HAL_LOG_INFO("load config from fs"); 88 | loadSystemConfig(); 89 | 90 | HAL_LOG_INFO("update device from config"); 91 | updateSystemFromConfig(); 92 | } 93 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_gamepad.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_gamepad.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../hal_rachel.h" 13 | #include 14 | #include "../hal_config.h" 15 | 16 | void HAL_Rachel::_gamepad_init() 17 | { 18 | spdlog::info("gamepad init"); 19 | HAL_LOG_INFO("gamepad init"); 20 | 21 | // Map pin to button 22 | _gamepad_key_map[GAMEPAD::BTN_START] = HAL_PIN_GAMEPAD_START; 23 | _gamepad_key_map[GAMEPAD::BTN_SELECT] = HAL_PIN_GAMEPAD_SELECT; 24 | _gamepad_key_map[GAMEPAD::BTN_UP] = HAL_PIN_GAMEPAD_UP; 25 | _gamepad_key_map[GAMEPAD::BTN_LEFT] = HAL_PIN_GAMEPAD_LEFT; 26 | _gamepad_key_map[GAMEPAD::BTN_RIGHT] = HAL_PIN_GAMEPAD_RIGHT; 27 | _gamepad_key_map[GAMEPAD::BTN_DOWN] = HAL_PIN_GAMEPAD_DOWN; 28 | _gamepad_key_map[GAMEPAD::BTN_X] = HAL_PIN_GAMEPAD_X; 29 | _gamepad_key_map[GAMEPAD::BTN_Y] = HAL_PIN_GAMEPAD_Y; 30 | _gamepad_key_map[GAMEPAD::BTN_A] = HAL_PIN_GAMEPAD_A; 31 | _gamepad_key_map[GAMEPAD::BTN_B] = HAL_PIN_GAMEPAD_B; 32 | _gamepad_key_map[GAMEPAD::BTN_LEFT_STICK] = HAL_PIN_GAMEPAD_LS; 33 | 34 | // GPIO init 35 | for (auto& i : _gamepad_key_map) 36 | { 37 | gpio_reset_pin((gpio_num_t)i); 38 | pinMode(i, INPUT_PULLUP); 39 | } 40 | 41 | _key_state_list.fill(false); 42 | } 43 | 44 | bool HAL_Rachel::getButton(GAMEPAD::GamePadButton_t button) 45 | { 46 | // return !(bool)(digitalRead(_gamepad_key_map[button])); 47 | 48 | if (!digitalRead(_gamepad_key_map[button])) 49 | { 50 | // If just pressed 51 | if (!_key_state_list[button]) 52 | { 53 | _key_state_list[button] = true; 54 | beep(600, 20); 55 | } 56 | 57 | return true; 58 | } 59 | 60 | // If just released 61 | if (_key_state_list[button]) 62 | { 63 | _key_state_list[button] = false; 64 | beep(800, 20); 65 | } 66 | 67 | return false; 68 | } 69 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_i2c.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_i2c.cpp 3 | * @author Forairaaaaa 4 | * @brief Ref: https://github.com/m5stack/M5Unified 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../hal_rachel.h" 13 | #include 14 | #include "../hal_config.h" 15 | 16 | void HAL_Rachel::_i2c_init() 17 | { 18 | spdlog::info("i2c bus init"); 19 | HAL_LOG_INFO("i2c bus init"); 20 | 21 | // Init bus 22 | _i2c_bus = new m5::I2C_Class; 23 | _i2c_bus->begin(I2C_NUM_0, HAL_PIN_I2C_SDA, HAL_PIN_I2C_SCL); 24 | 25 | // Scan 26 | bool scan_list[120]; 27 | _i2c_bus->scanID(scan_list); 28 | for (int i = 8; i < 0x78; i++) 29 | { 30 | if (scan_list[i]) 31 | { 32 | spdlog::info("i2c bus scan get: 0x{0:x}", i); 33 | HAL_LOG_INFO("i2c bus scan get: 0x%02X", i); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_imu.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_imu.cpp 3 | * @author Forairaaaaa 4 | * @brief Ref: https://github.com/m5stack/M5Unified 5 | * @version 0.1 6 | * @date 2023-11-08 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../hal_rachel.h" 13 | #include 14 | #include "../hal_config.h" 15 | 16 | void HAL_Rachel::_imu_init() 17 | { 18 | spdlog::info("imu init"); 19 | HAL_LOG_INFO("imu init"); 20 | 21 | _imu = new m5::IMU_Class(); 22 | if (!_imu->begin(_i2c_bus)) 23 | { 24 | spdlog::error("imu init failed!"); 25 | HAL_LOG_ERROR("imu init failed!"); 26 | } 27 | 28 | // // Test 29 | // while (1) 30 | // { 31 | // auto imu_update = _imu->update(); 32 | // if (imu_update) 33 | // { 34 | // // Obtain data on the current value of the IMU. 35 | // auto data = _imu->getImuData(); 36 | // printf("%f\t%f\t%f\n", data.accel.x, data.accel.y, data.accel.z); 37 | // } 38 | // delay(50); 39 | // } 40 | } 41 | 42 | void HAL_Rachel::updateImuData() 43 | { 44 | auto imu_update = _imu->update(); 45 | if (imu_update) 46 | { 47 | // Obtain data on the current value of the IMU. 48 | auto data = _imu->getImuData(); 49 | _imu_data.accelX = data.accel.x; 50 | _imu_data.accelY = data.accel.y; 51 | _imu_data.accelZ = data.accel.z; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_power.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_power.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../hal_rachel.h" 13 | #include 14 | #include "../hal_config.h" 15 | 16 | void HAL_Rachel::_power_init() 17 | { 18 | // Hold power 19 | gpio_reset_pin((gpio_num_t)HAL_PIN_PWR_HOLD); 20 | pinMode(HAL_PIN_PWR_HOLD, OUTPUT); 21 | digitalWrite(HAL_PIN_PWR_HOLD, 1); 22 | } 23 | 24 | void HAL_Rachel::powerOff() 25 | { 26 | digitalWrite(HAL_PIN_PWR_HOLD, 0); 27 | delay(1000); 28 | } 29 | 30 | void HAL_Rachel::reboot() 31 | { 32 | beepStop(); 33 | esp_restart(); 34 | } 35 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_rtc.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_rtc.cpp 3 | * @author Forairaaaaa 4 | * @brief Ref: https://github.com/m5stack/M5Unified 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../hal_rachel.h" 13 | #include 14 | #include "../hal_config.h" 15 | 16 | void HAL_Rachel::_rtc_init() 17 | { 18 | spdlog::info("rtc init"); 19 | HAL_LOG_INFO("rtc init"); 20 | 21 | _rtc = new m5::RTC8563_Class(0x51, 400000, _i2c_bus); 22 | if (!_rtc->begin()) 23 | { 24 | spdlog::error("rtc init failed!"); 25 | HAL_LOG_ERROR("rtc init failed!"); 26 | } 27 | 28 | _adjust_sys_time(); 29 | 30 | // // Test 31 | // tm set_time; 32 | // set_time.tm_year = 2023; 33 | // set_time.tm_mon = 10; 34 | // set_time.tm_mday = 8; 35 | // set_time.tm_wday = 3; 36 | // set_time.tm_hour = 16; 37 | // set_time.tm_min = 15; 38 | // set_time.tm_sec = 0; 39 | // this->setDateTime(set_time); 40 | 41 | // m5::rtc_time_t rtc_time; 42 | // m5::rtc_date_t rtc_date; 43 | // while (1) 44 | // { 45 | // _rtc->getTime(&rtc_time); 46 | // _rtc->getDate(&rtc_date); 47 | // printf("%02d:%02d:%02d %04d,%02d,%02d,%02d\n", 48 | // rtc_time.hours, 49 | // rtc_time.minutes, 50 | // rtc_time.seconds, 51 | // rtc_date.year, 52 | // rtc_date.month, 53 | // rtc_date.date, 54 | // rtc_date.weekDay 55 | // ); 56 | // this->delay(1000); 57 | // } 58 | } 59 | 60 | void HAL_Rachel::setSystemTime(tm dateTime) 61 | { 62 | _rtc->setDateTime(dateTime); 63 | _adjust_sys_time(); 64 | } 65 | 66 | void HAL_Rachel::_adjust_sys_time() 67 | { 68 | auto time = _rtc->getDateTime().get_tm(); 69 | time_t tv_sec = mktime(&time); 70 | struct timeval now = {.tv_sec = tv_sec}; 71 | settimeofday(&now, NULL); 72 | spdlog::info("adjusted system time to rtc"); 73 | } 74 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_sdcard.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_sdcard.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-08 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../hal_config.h" 16 | #include "../hal_rachel.h" 17 | 18 | void HAL_Rachel::_sdcard_init() 19 | { 20 | spdlog::info("sd card init"); 21 | HAL_LOG_INFO("sd card init"); 22 | 23 | if (!SD.begin(HAL_PIN_SD_CS, SPI)) 24 | { 25 | spdlog::warn("sd card init failed!"); 26 | HAL_LOG_WARN("sd card init failed!"); 27 | _is_sd_card_ready = false; 28 | return; 29 | } 30 | 31 | spdlog::info("sd card size: {}G", SD.cardSize() / 1073741824); 32 | HAL_LOG_INFO("sd card size: %ldG", SD.cardSize() / 1073741824); 33 | _is_sd_card_ready = true; 34 | } 35 | 36 | void HAL_Rachel::loadTextFont24() 37 | { 38 | bool ret = _canvas->loadFont(SD, "/fonts/font_text_24.vlw"); 39 | if (!ret) 40 | { 41 | spdlog::error("load font failed"); 42 | _canvas->setFont(&fonts::efontCN_24); 43 | } 44 | _canvas->setTextSize(1); 45 | } 46 | 47 | void HAL_Rachel::loadTextFont16() 48 | { 49 | // _canvas->setFont(&fonts::efontCN_16); 50 | // _canvas->setTextSize(1); 51 | } 52 | 53 | void HAL_Rachel::loadLauncherFont24() 54 | { 55 | // // 27fps, 37ms/f 56 | // loadTextFont24(); 57 | 58 | // 40fps, 25ms/f 59 | _canvas->setFont(&fonts::efontCN_24); 60 | _canvas->setTextSize(1); 61 | } 62 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/components/hal_speaker.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_speaker.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-08 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include 12 | #include "../hal_rachel.h" 13 | #include 14 | #include "../hal_config.h" 15 | 16 | void HAL_Rachel::_spk_init() 17 | { 18 | spdlog::info("buzz init"); 19 | HAL_LOG_INFO("buzz init"); 20 | 21 | // _spk = new m5::Speaker_Class; 22 | // auto cfg = _spk->config(); 23 | // cfg.buzzer = true; 24 | // cfg.pin_data_out = HAL_PIN_BUZZ; 25 | // _spk->config(cfg); 26 | 27 | // if (!_spk->begin()) 28 | // { 29 | // spdlog::error("buzz init failed!"); 30 | // HAL_LOG_ERROR("buzz init failed!"); 31 | // } 32 | 33 | // // Test 34 | // _spk->tone(4000, 300); 35 | // while (_spk->isPlaying()) 36 | // delay(20); 37 | // delay(1000); 38 | // _spk->tone(6000, 300); 39 | // while (_spk->isPlaying()) 40 | // delay(20); 41 | 42 | // _spk->setVolume(255); 43 | // delay(1000); 44 | 45 | // _spk->tone(4000, 300); 46 | // while (_spk->isPlaying()) 47 | // delay(20); 48 | // delay(1000); 49 | // _spk->tone(6000, 300); 50 | // while (_spk->isPlaying()) 51 | // delay(20); 52 | 53 | // while (1) 54 | // { 55 | // // _spk->begin(); 56 | // // for (int i = 100; i < 10000; i += 100) 57 | // // { 58 | // // spdlog::info("tone at: {}", i); 59 | // // _spk->tone(i, 200); 60 | // // delay(200); 61 | // // } 62 | // // _spk->stop(); 63 | 64 | // // 100 ~ 6000 (4000) 65 | // for (int i = 100; i < 10000; i += 100) 66 | // { 67 | // spdlog::info("arduino tone at: {}", i); 68 | // tone(HAL_PIN_BUZZ, i); 69 | // delay(200); 70 | // } 71 | 72 | // delay(2000); 73 | // } 74 | } 75 | 76 | void HAL_Rachel::beep(float frequency, uint32_t duration) 77 | { 78 | if (_config.volume == 0) 79 | return; 80 | 81 | // _spk->tone(frequency, duration); 82 | tone(HAL_PIN_BUZZ, frequency, duration); 83 | } 84 | 85 | void HAL_Rachel::beepStop() { noTone(HAL_PIN_BUZZ); } 86 | 87 | void HAL_Rachel::setBeepVolume(uint8_t volume) 88 | { 89 | // _spk->setVolume(volume); 90 | } 91 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/hal_rachel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_rachel.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-07 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include "../hal.h" 13 | #include "utils/m5unified/I2C_Class.hpp" 14 | #include "utils/m5unified/RTC8563_Class.hpp" 15 | #include "utils/m5unified/IMU_Class.hpp" 16 | // #include "utils/m5unified/Speaker_Class.hpp" 17 | 18 | class HAL_Rachel : public HAL 19 | { 20 | private: 21 | std::array _gamepad_key_map; 22 | std::array _key_state_list; 23 | m5::I2C_Class* _i2c_bus; 24 | m5::RTC8563_Class* _rtc; 25 | m5::IMU_Class* _imu; 26 | // m5::Speaker_Class* _spk; 27 | 28 | private: 29 | void _power_init(); 30 | void _disp_init(); 31 | void _disp_logo(); 32 | void _fs_init(); 33 | void _i2c_init(); 34 | void _rtc_init(); 35 | void _imu_init(); 36 | void _spk_init(); 37 | void _sdcard_init(); 38 | void _gamepad_init(); 39 | void _adjust_sys_time(); 40 | void _system_config_init(); 41 | void _sum_up(); 42 | 43 | public: 44 | HAL_Rachel() : _i2c_bus(nullptr), _rtc(nullptr), _imu(nullptr) 45 | // _spk(nullptr) 46 | { 47 | } 48 | ~HAL_Rachel() 49 | { 50 | delete _rtc; 51 | delete _imu; 52 | delete _i2c_bus; 53 | // delete _spk; 54 | } 55 | 56 | inline std::string type() override { return "Rachel"; } 57 | 58 | inline void init() override 59 | { 60 | _power_init(); 61 | _disp_init(); 62 | _gamepad_init(); 63 | _spk_init(); 64 | _i2c_init(); 65 | _rtc_init(); 66 | _imu_init(); 67 | _fs_init(); 68 | _sdcard_init(); 69 | _system_config_init(); 70 | _sum_up(); 71 | } 72 | 73 | void reboot() override; 74 | void loadTextFont24() override; 75 | void loadTextFont16() override; 76 | void loadLauncherFont24() override; 77 | 78 | bool getButton(GAMEPAD::GamePadButton_t button) override; 79 | void powerOff() override; 80 | void setSystemTime(tm dateTime) override; 81 | void updateImuData() override; 82 | void beep(float frequency, uint32_t duration) override; 83 | void beepStop() override; 84 | void setBeepVolume(uint8_t volume) override; 85 | void loadSystemConfig() override; 86 | void saveSystemConfig() override; 87 | }; 88 | -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/utils/m5unified/imu/IMU_Base.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) M5Stack. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include "IMU_Base.hpp" 5 | 6 | namespace m5 7 | { 8 | IMU_Base::~IMU_Base() {} 9 | IMU_Base::IMU_Base(std::uint8_t i2c_addr, std::uint32_t freq, I2C_Class* i2c) : I2C_Device(i2c_addr, freq, i2c) {} 10 | /* 11 | int32_t IMU_Base::point3d_i32_t::calibration(const point3d_i16_t& dst) 12 | { 13 | { // 前回の座標情報との差が許容範囲よりも大きく移動しているか調べる 14 | int32_t moving_distance = 0; 15 | for (int i = 0; i < 3; ++i) 16 | { 17 | int32_t diff = dst.value[i] - prev_point.value[i]; 18 | moving_distance += diff * diff; 19 | } 20 | prev_point = dst; 21 | uint32_t wait = wait_counter; 22 | if (moving_distance > (tolerance * tolerance)) 23 | { // 移動変化量が大きい場合は補正を暫く停止する 24 | wait = 16; 25 | } 26 | if (wait) 27 | { // 座標移動が安定するまで待機 28 | wait_counter = wait - 1; 29 | return 0; 30 | } 31 | } 32 | 33 | float distance = 0; 34 | float diffs[3]; 35 | for (int i = 0; i < 3; ++i) 36 | { 37 | float diff = (dst.value[i] << 16) - value[i]; 38 | diffs[i] = diff; 39 | distance += diff * diff; 40 | } 41 | distance = sqrtf(distance * (1.0f / (65536.0f * 65536.0f))); 42 | 43 | // 誤差を求める (目的の半径と現在の距離の差) 44 | float measure_error = distance - radius; 45 | 46 | int32_t tol = tolerance; 47 | int32_t force = abs((int32_t)measure_error) - tol; 48 | if (force <= 0) { return 1; } 49 | 50 | if (force > tol) { force = tol; } 51 | if (signbit(measure_error)) { force = -force; } 52 | 53 | float fk = (force * strength) / (distance * 256.0f); 54 | for (int i = 0; i < 3; ++i) 55 | { 56 | value[i] += diffs[i] * fk; 57 | } 58 | return 0; 59 | } 60 | //*/ 61 | } // namespace m5 -------------------------------------------------------------------------------- /src/rachel/hal/hal_rachel/utils/m5unified/imu/IMU_Base.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) M5Stack. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #ifndef __M5_IMU_BASE_H__ 5 | #define __M5_IMU_BASE_H__ 6 | 7 | #include "../I2C_Class.hpp" 8 | 9 | namespace m5 10 | { 11 | class IMU_Base : public I2C_Device 12 | { 13 | public: 14 | enum imu_spec_t 15 | { 16 | imu_spec_none = 0, 17 | imu_spec_accel = 0b0001, 18 | imu_spec_gyro = 0b0010, 19 | imu_spec_mag = 0b0100, 20 | }; 21 | 22 | struct point3d_i16_t 23 | { 24 | union 25 | { 26 | int16_t value[3]; 27 | struct 28 | { 29 | int16_t x; 30 | int16_t y; 31 | int16_t z; 32 | }; 33 | } __attribute__((__packed__)); 34 | }; 35 | 36 | struct imu_raw_data_t 37 | { 38 | union 39 | { 40 | int16_t value[10] = { 41 | 0, 42 | }; 43 | point3d_i16_t sensor[3]; 44 | struct 45 | { 46 | point3d_i16_t accel; 47 | point3d_i16_t gyro; 48 | point3d_i16_t mag; 49 | int16_t temp; 50 | } __attribute__((__packed__)); 51 | }; 52 | }; 53 | 54 | struct imu_convert_param_t 55 | { 56 | union 57 | { 58 | float value[3] = {8.0f / 32768.0f, 2000.0f / 32768.0f, 10.0f * 4912.0f / 32768.0f}; 59 | struct 60 | { 61 | float accel_res; 62 | float gyro_res; 63 | float mag_res; 64 | }; 65 | }; 66 | float temp_res = 1.0f; 67 | float temp_offset = 0.0f; 68 | }; 69 | 70 | virtual ~IMU_Base(); 71 | IMU_Base(std::uint8_t i2c_addr, std::uint32_t freq = 400000, I2C_Class* i2c = nullptr); 72 | virtual imu_spec_t begin(I2C_Class* i2c = nullptr) = 0; 73 | virtual imu_spec_t getImuRawData(imu_raw_data_t* data) const = 0; //{ return (imu_spec_t)0; } 74 | virtual void getConvertParam(imu_convert_param_t* param) const = 0; //{} 75 | virtual bool getTempAdc(int16_t* adc) const { return false; }; 76 | 77 | /* 78 | virtual bool getAccelAdc(std::int16_t* ax, std::int16_t* ay, std::int16_t* az) const { return false; } 79 | virtual bool getGyroAdc(std::int16_t* gx, std::int16_t* gy, std::int16_t* gz) const { return false; } 80 | virtual bool getAccel(float* ax, float* ay, float* az) const { return false; } 81 | virtual bool getGyro(float* gx, float* gy, float* gz) const { return false; } 82 | virtual bool getTemp(float *t) const { return false; }; 83 | //*/ 84 | 85 | virtual bool setINTPinActiveLogic(bool level) { return false; } 86 | }; 87 | } // namespace m5 88 | 89 | #endif -------------------------------------------------------------------------------- /src/rachel/hal/hal_simulator/hal_simulator.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_simulator.hpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #ifndef ESP_PLATFORM 13 | #include "lgfx/v1/LGFX_Sprite.hpp" 14 | #include "lgfx/v1/platforms/sdl/common.hpp" 15 | #define LGFX_USE_V1 16 | #include 17 | #include 18 | #include "lgfx/v1/lgfx_fonts.hpp" 19 | #include "../hal.h" 20 | #include "../../../performance_window.hpp" 21 | 22 | // PerformanceWindow _pw; 23 | 24 | class HAL_Simulator : public HAL 25 | { 26 | std::string type() override { return "Simulator"; } 27 | 28 | void init() override 29 | { 30 | // Display 31 | _display = new LGFX(240, 240); 32 | _display->init(); 33 | 34 | // Canvas 35 | _canvas = new LGFX_SpriteFx(_display); 36 | _canvas->createSprite(_display->width(), _display->height()); 37 | 38 | // // Some pc window pop up slower? 39 | // lgfx::delay(1500); 40 | 41 | // this->popFatalError("啊?"); 42 | // this->popFatalError("原神启动失败(悲)"); 43 | } 44 | 45 | void canvasUpdate() override 46 | { 47 | GetCanvas()->pushSprite(0, 0); 48 | // _pw.update(); 49 | } 50 | 51 | void loadTextFont24() override 52 | { 53 | // https://github.com/Bodmer/TFT_eSPI/tree/master/Tools/Create_Smooth_Font/Create_font 54 | // http://lvgl.100ask.net/8.1/tools/fonts-zh-source.html#id7 55 | // https://r12a.github.io/app-conversion/ 56 | _canvas->loadFont("../rachel/apps/assets/fonts/zpix_cn_24.vlw"); 57 | _canvas->setTextSize(1); 58 | } 59 | 60 | void loadTextFont16() override 61 | { 62 | _canvas->setFont(&fonts::efontCN_16); 63 | _canvas->setTextSize(1); 64 | } 65 | 66 | void loadLauncherFont24() override 67 | { 68 | // loadTextFont24(); 69 | _canvas->setFont(&fonts::efontCN_24); 70 | _canvas->setTextSize(1); 71 | } 72 | 73 | bool getButton(GAMEPAD::GamePadButton_t button) override 74 | { 75 | if (button == GAMEPAD::BTN_A) 76 | return !lgfx::gpio_in(36); 77 | else if (button == GAMEPAD::BTN_LEFT) 78 | return !lgfx::gpio_in(39); 79 | else if (button == GAMEPAD::BTN_RIGHT) 80 | return !lgfx::gpio_in(37); 81 | // else if (button == GAMEPAD::BTN_B) 82 | // return !lgfx::gpio_in(38); 83 | // else if (button == GAMEPAD::BTN_SELECT) 84 | // return !lgfx::gpio_in(38); 85 | // else if (button == GAMEPAD::BTN_UP) 86 | // return !lgfx::gpio_in(39); 87 | // else if (button == GAMEPAD::BTN_DOWN) 88 | // return !lgfx::gpio_in(37); 89 | else if (button == GAMEPAD::BTN_START) 90 | return !lgfx::gpio_in(38); 91 | 92 | return false; 93 | } 94 | }; 95 | #endif 96 | -------------------------------------------------------------------------------- /src/rachel/hal/lgfx_fx/lgfx_fx.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lgfx_fx.hpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-11 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | #include 13 | 14 | /** 15 | * @brief Add apis to fill shape layer in difference mode 16 | * 17 | */ 18 | class LGFX_SpriteFx : public LGFX_Sprite 19 | { 20 | public: 21 | LGFX_SpriteFx(LovyanGFX* parent) : LGFX_Sprite(parent) {} 22 | 23 | void drawFastHLineInDifference(int32_t x, int32_t y, int32_t w); 24 | void fillRectInDifference(int32_t x, int32_t y, int32_t w, int32_t h); 25 | void fillSmoothRoundRectInDifference(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r); 26 | inline void fillSmoothCircleInDifference(int32_t x, int32_t y, int32_t r) 27 | { 28 | fillSmoothRoundRectInDifference(x - r, y - r, r * 2 + 1, r * 2 + 1, r); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /src/rachel/rachel.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rachel.cpp 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #include "rachel.h" 12 | #include 13 | #include "hal/hal.h" 14 | #ifndef ESP_PLATFORM 15 | #include "hal/hal_simulator/hal_simulator.hpp" 16 | #else 17 | #include "hal/hal_rachel/hal_rachel.h" 18 | #endif 19 | #include "apps/apps.h" 20 | 21 | using namespace MOONCAKE; 22 | static Mooncake* _mooncake = nullptr; 23 | 24 | void RACHEL::Setup() 25 | { 26 | spdlog::info("Rachel Setup"); 27 | 28 | // HAL injection 29 | #ifndef ESP_PLATFORM 30 | HAL::Inject(new HAL_Simulator); 31 | #else 32 | HAL::Inject(new HAL_Rachel); 33 | #endif 34 | 35 | // Mooncake framework 36 | _mooncake = new Mooncake; 37 | _mooncake->init(); 38 | 39 | // Install launcher 40 | auto launcher = new APPS::Launcher_Packer; 41 | _mooncake->installApp(launcher); 42 | 43 | // Install apps 44 | rachel_app_install_callback(_mooncake); 45 | 46 | // Create launcher 47 | _mooncake->createApp(launcher); 48 | } 49 | 50 | void RACHEL::Loop() { _mooncake->update(); } 51 | 52 | void RACHEL::Destroy() 53 | { 54 | // Free 55 | delete _mooncake; 56 | HAL::Destroy(); 57 | spdlog::warn("Rachel destroy"); 58 | } 59 | -------------------------------------------------------------------------------- /src/rachel/rachel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rachel.h 3 | * @author Forairaaaaa 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-04 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | #pragma once 12 | 13 | namespace RACHEL 14 | { 15 | void Setup(); 16 | void Loop(); 17 | void Destroy(); 18 | } // namespace RACHEL 19 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Test Runner and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/en/latest/advanced/unit-testing/index.html 12 | --------------------------------------------------------------------------------