├── .gitattributes ├── wiring schematic.xlsx ├── lib ├── menu │ ├── data │ │ └── image.jpg │ ├── component.mk │ ├── src │ │ ├── menu.h │ │ ├── decode_image.h │ │ ├── pretty_effect.h │ │ ├── charPixels.c │ │ └── decode_image.c │ └── Kconfig.projbuild ├── nofrendo │ ├── AUTHORS │ ├── component.mk │ ├── src │ │ ├── esp32 │ │ │ ├── psxcontroller.h │ │ │ ├── spi_lcd.h │ │ │ └── osd.c │ │ ├── nes │ │ │ ├── mmclist.h │ │ │ ├── nesstate.h │ │ │ ├── nes_pal.h │ │ │ ├── nesinput.h │ │ │ ├── nes_rom.h │ │ │ ├── mmclist.c │ │ │ └── nes_mmc.h │ │ ├── intro.h │ │ ├── sndhrdw │ │ │ ├── fds_snd.h │ │ │ ├── mmc5_snd.h │ │ │ ├── vrcvisnd.h │ │ │ └── fds_snd.c │ │ ├── cpu │ │ │ ├── dis6502.h │ │ │ └── nes6502.h │ │ ├── log.h │ │ ├── mappers │ │ │ ├── map000.c │ │ │ ├── map093.c │ │ │ ├── map002.c │ │ │ ├── map003.c │ │ │ ├── map094.c │ │ │ ├── map099.c │ │ │ ├── map079.c │ │ │ ├── map066.c │ │ │ ├── map011.c │ │ │ ├── map008.c │ │ │ ├── map231.c │ │ │ ├── map087.c │ │ │ ├── map007.c │ │ │ ├── map034.c │ │ │ ├── map032.c │ │ │ ├── map078.c │ │ │ ├── map070.c │ │ │ ├── map229.c │ │ │ ├── map075.c │ │ │ ├── map160.c │ │ │ ├── map065.c │ │ │ ├── map033.c │ │ │ ├── map015.c │ │ │ ├── map040.c │ │ │ ├── map046.c │ │ │ ├── map019.c │ │ │ ├── map016.c │ │ │ ├── map073.c │ │ │ └── map041.c │ │ ├── gui_elem.h │ │ ├── version.h │ │ ├── nofconfig.h │ │ ├── pcx.h │ │ ├── bitmap.h │ │ ├── nofrendo.h │ │ ├── memguard.h │ │ ├── noftypes.h │ │ ├── pcx.c │ │ ├── gui.h │ │ ├── event.h │ │ ├── log.c │ │ ├── bitmap.c │ │ └── vid_drv.h │ └── library.json └── README ├── .gitignore ├── partitions.csv ├── data └── roms.txt ├── boards └── ke32-wrover-c20.json ├── include └── README ├── Case design └── readme.md └── platformio.ini /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /wiring schematic.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badvision/esp32_nesemu/HEAD/wiring schematic.xlsx -------------------------------------------------------------------------------- /lib/menu/data/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badvision/esp32_nesemu/HEAD/lib/menu/data/image.jpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | .pioenvs/ 3 | .vscode/ 4 | sdkconfig.old 5 | *.nes 6 | 7 | /~$wiring schematic revised.xlsx 8 | -------------------------------------------------------------------------------- /lib/menu/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main Makefile. This is basically the same as a component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | 6 | 7 | #Compile image file into the resulting firmware binary 8 | #COMPONENT_EMBED_FILES := image.jpg 9 | COMPONENT_ADD_INCLUDEDIRS := . -------------------------------------------------------------------------------- /partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 0x60000, 6 | rom, data, 0xff, 0x70000, 512k, 7 | storage, data, spiffs, , 3M -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/nofrendo/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Component Makefile 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | 10 | COMPONENT_ADD_INCLUDEDIRS := cpu libsnss nes sndhrdw . 11 | COMPONENT_SRCDIRS := cpu libsnss nes sndhrdw mappers . 12 | 13 | CFLAGS += -Wno-error=char-subscripts -Wno-error=attributes -DNOFRENDO_DEBUG 14 | -------------------------------------------------------------------------------- /lib/menu/src/menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "esp_err.h" 4 | 5 | /** 6 | * @brief running intro and menu (choose rom/game) 7 | * 8 | * @return - integer for choosing game partition 9 | */ 10 | #define ROM_LIST "/spiffs/roms.txt" 11 | #define FILENAME_LENGTH 18 12 | 13 | char* runMenu(); 14 | void setBr(int bright); 15 | void freeMenuResources(); 16 | 17 | typedef struct menuEntry 18 | { 19 | int entryNumber; 20 | char icon; 21 | char name[FILENAME_LENGTH+1]; 22 | char fileName[FILENAME_LENGTH+1]; 23 | } MenuEntry; 24 | int entryCount; 25 | MenuEntry *menuEntries; 26 | -------------------------------------------------------------------------------- /lib/menu/src/decode_image.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "esp_err.h" 4 | 5 | /** 6 | * @brief Decode the jpeg ``image.jpg`` embedded into the program file into pixel data. 7 | * 8 | * @param pixels A pointer to a pointer for an array of rows, which themselves are an array of pixels. 9 | * Effectively, you can get the pixel data by doing ``decode_image(&myPixels); pixelval=myPixels[ypos][xpos];`` 10 | * @return - ESP_ERR_NOT_SUPPORTED if image is malformed or a progressive jpeg file 11 | * - ESP_ERR_NO_MEM if out of memory 12 | * - ESP_OK on succesful decode 13 | */ 14 | esp_err_t decode_image(uint16_t ***pixels); -------------------------------------------------------------------------------- /lib/nofrendo/src/esp32/psxcontroller.h: -------------------------------------------------------------------------------- 1 | #ifndef PSXCONTROLLER_H 2 | #define PSXCONTROLLER_H 3 | 4 | int psxReadInput(); 5 | void psxcontrollerInit(); 6 | bool getShowMenu(); 7 | int getBright(); 8 | int getVolume(); 9 | bool getShutdown(); 10 | bool isSelectPressed(int ctl); 11 | bool isStartPressed(int ctl); 12 | bool isUpPressed(int ctl); 13 | bool isRightPressed(int ctl); 14 | bool isDownPressed(int ctl); 15 | bool isLeftPressed(int ctl); 16 | bool isAPressed(int ctl); 17 | bool isBPressed(int ctl); 18 | bool isTurboAPressed(int ctl); 19 | bool isTurboBPressed(int ctl); 20 | bool isMenuPressed(int ctl); 21 | bool isPowerPressed(int ctl); 22 | bool isAnyPressed(int ctl); 23 | bool isAnyFirePressed(int ctl); 24 | int getTurboA(); 25 | int getTurboB(); 26 | 27 | #endif -------------------------------------------------------------------------------- /lib/menu/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "Example Configuration" 2 | 3 | choice LCD_TYPE 4 | prompt "LCD module type" 5 | default LCD_TYPE_AUTO 6 | help 7 | The type of LCD on the evaluation board. 8 | 9 | config LCD_TYPE_AUTO 10 | bool "Auto detect" 11 | config LCD_TYPE_ST7789V 12 | bool "ST7789V (WROVER Kit v2 or v3)" 13 | config LCD_TYPE_ILI9341 14 | bool "ILI9341 (WROVER Kit v1 or DevKitJ v1)" 15 | endchoice 16 | 17 | config LCD_OVERCLOCK 18 | bool 19 | prompt "Run LCD at higher clock speed than allowed" 20 | default "n" 21 | help 22 | The ILI9341 and ST7789 specify that the maximum clock speed for the SPI interface is 10MHz. However, 23 | in practice the driver chips work fine with a higher clock rate, and using that gives a better framerate. 24 | Select this to try using the out-of-spec clock rate. 25 | 26 | endmenu 27 | -------------------------------------------------------------------------------- /lib/menu/src/pretty_effect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "esp_err.h" 4 | 5 | 6 | /** 7 | * @brief Calculate and disaply a set of rows to the screen 8 | * 9 | * @param dest Destination for the pixels. Assumed to be LINECT * 320 16-bit pixel values. 10 | * @param y Starting y coordinate of the chunk of lines. 11 | * @param rowCount Amount of lines to calculate 12 | */ 13 | void drawRows(uint16_t *dest, int y, int rowCount); 14 | 15 | void handleUserInput(); 16 | 17 | /** 18 | * @brief Initialize the boot screen and menu 19 | * 20 | * @return ESP_OK on success, an error from the jpeg decoder otherwise. 21 | */ 22 | esp_err_t menuInit(); 23 | 24 | bool peGetPixel(char peChar, int pe1, int pe2); 25 | 26 | void setLineMax(int lineM); 27 | 28 | int getSelRom(); 29 | 30 | void setSelRom(int selR); 31 | 32 | void freeMem(); 33 | 34 | bool getYStretch(); 35 | 36 | bool getXStretch(); 37 | 38 | void setXStretch(bool str); 39 | 40 | void setYStretch(bool str); 41 | 42 | void setBright(int bright); -------------------------------------------------------------------------------- /lib/nofrendo/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Nofrendo", 3 | "description": "Nofrendo emulator core", 4 | "keywords": "nes, nintendo, nofrendo", 5 | "authors": 6 | { 7 | "name": "TODO:Fill this in", 8 | "email": "", 9 | "url": "" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/stanleyhuangyc/Freematics.git" 14 | }, 15 | "export":{ 16 | "include":[ 17 | "src/*", 18 | "src/nes/*", 19 | "src/esp32/*" 20 | ] 21 | }, 22 | "srcFilter": [ 23 | "+<*>", 24 | "+", 25 | "+", 26 | "+", 27 | "+", 28 | "+", 29 | "+" 30 | ], 31 | "build":{ 32 | "flags":[ 33 | "-Isrc/cpu", 34 | "-Isrc/libsnss", 35 | "-Isrc/mappers", 36 | "-Isrc/nes", 37 | "-Isrc/sndhrdw", 38 | "-Isrc/esp32" 39 | ] 40 | }, 41 | "frameworks": "*", 42 | "platforms": "*" 43 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /data/roms.txt: -------------------------------------------------------------------------------- 1 | No. Icon Name Filename 2 | 1. $ Super Mario Bros 1 smb1.nes 3 | 2. " Super Mario Bros 3 smb3.nes 4 | 3. ; Tetris tetris.nes 5 | 4. = Legend of Zelda zelda1.nes 6 | 5. + Adventure of Link zelda2.nes 7 | 6. } Galaga galaga.nes 8 | 7. ; Metroid metroid.nes 9 | *#* 10 | NOTE: The rest of this file is ignored by the program 11 | 2. % Super Mario Bros 2 smb2.nes 12 | 7. / Contra contra.nes 13 | 10. $ Castlevania cv1.nes 14 | 11. / Simon's Quest cv2.nes 15 | 12. { Bubble Bobble bubble.nes 16 | 17 | # To flash roms, place in this directory and use the Platform.IO Upload File System Image task. 18 | # The character delimiter of the table above is tab, not spaces. 19 | # Don't erase this characters "*#*" or the emulator will definetly act up since that is the EOF marker. 20 | # 21 | # Note the four tab-delimited columns. All four should exist or the menu will not parse correctly. 22 | # There should be a period after the number, followed by an icon character, name, and file name. 23 | # The last column should match the ROM file name in the SPIFFS volume. 24 | # The menu will display the Alphabet (A-z capital & lowercas) 25 | # Numbers 0-9 and ? ! . , ( ) - 26 | # Icons: $ -> Mario % -> Luigi " -> MarioTanuki 27 | # ; -> Coin } -> ?-Box = -> Link1 28 | # + -> Link2 { -> Pacman / -> Megaman -------------------------------------------------------------------------------- /lib/nofrendo/src/esp32/spi_lcd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _DRIVER_SPI_LCD_H_ 15 | #define _DRIVER_SPI_LCD_H_ 16 | #include 17 | 18 | //***************************************************************************** 19 | // 20 | // Make sure all of the definitions in this header have a C binding. 21 | // 22 | //***************************************************************************** 23 | 24 | #ifdef __cplusplus 25 | extern "C" 26 | { 27 | #endif 28 | 29 | void ili9341_write_frame(const uint16_t x, const uint16_t y, const uint16_t width, const uint16_t height, const uint8_t *data[], 30 | bool xStr, bool yStr); 31 | void ili9341_init(); 32 | 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif // __SPI_H__ 39 | -------------------------------------------------------------------------------- /boards/ke32-wrover-c20.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "esp32", 4 | "extra_flags": "-DARDUINO_ESP32_DEV -mfix-esp32-psram-cache-issue", 5 | "f_cpu": "240000000L", 6 | "f_flash": "80000000L", 7 | "flash_mode": "dio", 8 | "hwids": [ 9 | [ 10 | "0x0403", 11 | "0x6010" 12 | ] 13 | ], 14 | "ldscript": "esp32_out.ld", 15 | "mcu": "esp32", 16 | "variant": "esp32" 17 | }, 18 | "connectivity": [ 19 | "wifi", 20 | "bluetooth", 21 | "ethernet", 22 | "can" 23 | ], 24 | "debug": { 25 | "default_tool": "ftdi", 26 | "onboard_tools": [ 27 | "ftdi" 28 | ], 29 | "openocd_board": "esp32-wrover.cfg" 30 | }, 31 | "frameworks": [ 32 | "arduino", 33 | "espidf" 34 | ], 35 | "name": "Geekwork ESP32-WROVER", 36 | "upload": { 37 | "flash_size": "8MB", 38 | "maximum_ram_size": 532480, 39 | "maximum_size": 8388608, 40 | "protocols": [ 41 | "esptool", 42 | "espota", 43 | "ftdi" 44 | ], 45 | "require_upload_port": true, 46 | "speed": 921600 47 | }, 48 | "url": "https://espressif.com/en/products/hardware/esp-wrover-kit/overview", 49 | "vendor": "Espressif" 50 | } -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /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/nofrendo/src/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 | extern char* selectedRomFilename; 32 | char configfilename[]="na"; 33 | 34 | /* This is os-specific part of main() */ 35 | int osd_main(int argc, char *argv[]) 36 | { 37 | config.filename = configfilename; 38 | 39 | printf("Starting main loop with file: %s\n", selectedRomFilename); 40 | return main_loop(selectedRomFilename, system_autodetect); 41 | } 42 | 43 | /* File system interface */ 44 | void osd_fullname(char *fullname, const char *shortname) 45 | { 46 | strncpy(fullname, shortname, PATH_MAX); 47 | } 48 | 49 | /* This gives filenames for storage of saves; DESTRUCTIVE */ 50 | char *osd_newextension(char *name, char *ext) 51 | { 52 | int len=strlen(name); 53 | name[len-4] = ext[0]; 54 | name[len-3] = ext[1]; 55 | name[len-2] = ext[2]; 56 | name[len-1] = ext[3]; 57 | 58 | return name; 59 | } 60 | 61 | /* This gives filenames for storage of PCX snapshots */ 62 | int osd_makesnapname(char *filename, int len) 63 | { 64 | return -1; 65 | } 66 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | 34 | #endif /* _VRCVISND_H_ */ 35 | 36 | /* 37 | ** $Log: fds_snd.h,v $ 38 | ** Revision 1.2 2001/04/27 14:37:11 neil 39 | ** wheeee 40 | ** 41 | ** Revision 1.1 2001/04/27 12:54:40 neil 42 | ** blah 43 | ** 44 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 45 | ** initial 46 | ** 47 | ** Revision 1.1 2000/10/24 12:19:59 matt 48 | ** changed directory structure 49 | ** 50 | ** Revision 1.3 2000/07/17 01:52:31 matt 51 | ** made sure last line of all source files is a newline 52 | ** 53 | ** Revision 1.2 2000/06/20 04:06:16 matt 54 | ** migrated external sound definition to apu module 55 | ** 56 | ** Revision 1.1 2000/06/20 00:06:47 matt 57 | ** initial revision 58 | ** 59 | */ 60 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | #endif /* __cplusplus */ 32 | 33 | extern char *nes6502_disasm(uint32 PC, uint8 P, uint8 A, uint8 X, uint8 Y, uint8 S); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif /* __cplusplus */ 38 | 39 | #endif /* !_DIS6502_H_ */ 40 | 41 | /* 42 | ** $Log: dis6502.h,v $ 43 | ** Revision 1.1 2001/04/27 12:54:39 neil 44 | ** blah 45 | ** 46 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 47 | ** initial 48 | ** 49 | ** Revision 1.6 2000/07/17 01:52:28 matt 50 | ** made sure last line of all source files is a newline 51 | ** 52 | ** Revision 1.5 2000/07/11 04:26:23 matt 53 | ** rewrote to fill up a static buffer, rather than use log_printf 54 | ** 55 | ** Revision 1.4 2000/06/09 15:12:25 matt 56 | ** initial revision 57 | ** 58 | */ 59 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | { 31 | 0, /* mapper number */ 32 | "None", /* mapper name */ 33 | NULL, /* init routine */ 34 | NULL, /* vblank callback */ 35 | NULL, /* hblank callback */ 36 | NULL, /* get state (snss) */ 37 | NULL, /* set state (snss) */ 38 | NULL, /* memory read structure */ 39 | NULL, /* memory write structure */ 40 | NULL /* external sound device */ 41 | }; 42 | 43 | /* 44 | ** $Log: map000.c,v $ 45 | ** Revision 1.2 2001/04/27 14:37:11 neil 46 | ** wheeee 47 | ** 48 | ** Revision 1.1 2001/04/27 12:54:40 neil 49 | ** blah 50 | ** 51 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 52 | ** initial 53 | ** 54 | ** Revision 1.1 2000/10/24 12:19:32 matt 55 | ** changed directory structure 56 | ** 57 | ** Revision 1.2 2000/07/06 02:48:43 matt 58 | ** clearly labelled structure members 59 | ** 60 | ** Revision 1.1 2000/07/04 23:11:45 matt 61 | ** initial revision 62 | ** 63 | */ 64 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | #endif /* _NESSTATE_H_ */ 36 | 37 | /* 38 | ** $Log: nesstate.h,v $ 39 | ** Revision 1.2 2001/04/27 14:37:11 neil 40 | ** wheeee 41 | ** 42 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 43 | ** initial 44 | ** 45 | ** Revision 1.2 2000/10/25 00:23:16 matt 46 | ** makefiles updated for new directory structure 47 | ** 48 | ** Revision 1.1 2000/10/24 12:20:28 matt 49 | ** changed directory structure 50 | ** 51 | ** Revision 1.4 2000/10/23 17:50:47 matt 52 | ** adding fds support 53 | ** 54 | ** Revision 1.3 2000/07/25 02:21:23 matt 55 | ** changed routine names to reduce confusion with SNSS routines 56 | ** 57 | ** Revision 1.2 2000/07/17 01:52:28 matt 58 | ** made sure last line of all source files is a newline 59 | ** 60 | ** Revision 1.1 2000/06/29 03:08:18 matt 61 | ** initial revision 62 | ** 63 | */ 64 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 44 | { 45 | { 0x8000, 0xFFFF, map93_write }, 46 | { -1, -1, NULL } 47 | }; 48 | 49 | mapintf_t map93_intf = 50 | { 51 | 93, /* mapper number */ 52 | "Mapper 93", /* mapper name */ 53 | NULL, /* init routine */ 54 | NULL, /* vblank callback */ 55 | NULL, /* hblank callback */ 56 | NULL, /* get state (snss) */ 57 | NULL, /* set state (snss) */ 58 | NULL, /* memory read structure */ 59 | map93_memwrite, /* memory write structure */ 60 | NULL /* external sound device */ 61 | }; 62 | 63 | /* 64 | ** $Log: map093.c,v $ 65 | ** Revision 1.2 2001/04/27 14:37:11 neil 66 | ** wheeee 67 | ** 68 | ** Revision 1.1 2001/04/27 12:54:40 neil 69 | ** blah 70 | ** 71 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 72 | ** initial 73 | ** 74 | ** Revision 1.1 2000/12/11 12:33:48 matt 75 | ** initial revision 76 | ** 77 | */ 78 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(16, 0x8000, value); 35 | } 36 | 37 | static map_memwrite map2_memwrite[] = 38 | { 39 | { 0x8000, 0xFFFF, map2_write }, 40 | { -1, -1, NULL } 41 | }; 42 | 43 | mapintf_t map2_intf = 44 | { 45 | 2, /* mapper number */ 46 | "UNROM", /* mapper name */ 47 | NULL, /* 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 | map2_memwrite, /* memory write structure */ 54 | NULL /* external sound device */ 55 | }; 56 | 57 | /* 58 | ** $Log: map002.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:32 matt 69 | ** changed directory structure 70 | ** 71 | ** Revision 1.5 2000/10/22 19:17:46 matt 72 | ** mapper cleanups galore 73 | ** 74 | ** Revision 1.4 2000/10/21 19:33:38 matt 75 | ** many more cleanups 76 | ** 77 | ** Revision 1.3 2000/08/16 02:50:11 matt 78 | ** random mapper cleanups 79 | ** 80 | ** Revision 1.2 2000/07/06 02:48:43 matt 81 | ** clearly labelled structure members 82 | ** 83 | ** Revision 1.1 2000/07/04 23:11:45 matt 84 | ** initial revision 85 | ** 86 | */ 87 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 38 | { 39 | { 0x8000, 0xFFFF, map3_write }, 40 | { -1, -1, NULL } 41 | }; 42 | 43 | mapintf_t map3_intf = 44 | { 45 | 3, /* mapper number */ 46 | "CNROM", /* mapper name */ 47 | NULL, /* 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 | map3_memwrite, /* memory write structure */ 54 | NULL /* external sound device */ 55 | }; 56 | 57 | /* 58 | ** $Log: map003.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:32 matt 69 | ** changed directory structure 70 | ** 71 | ** Revision 1.5 2000/10/22 19:17:46 matt 72 | ** mapper cleanups galore 73 | ** 74 | ** Revision 1.4 2000/10/21 19:33:38 matt 75 | ** many more cleanups 76 | ** 77 | ** Revision 1.3 2000/08/16 02:50:11 matt 78 | ** random mapper cleanups 79 | ** 80 | ** Revision 1.2 2000/07/06 02:48:43 matt 81 | ** clearly labelled structure members 82 | ** 83 | ** Revision 1.1 2000/07/04 23:11:45 matt 84 | ** initial revision 85 | ** 86 | */ 87 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 39 | { 40 | { 0x8000, 0xFFFF, map94_write }, 41 | { -1, -1, NULL } 42 | }; 43 | 44 | mapintf_t map94_intf = 45 | { 46 | 94, /* mapper number */ 47 | "Mapper 94", /* 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 | map94_memwrite, /* memory write structure */ 55 | NULL /* external sound device */ 56 | }; 57 | 58 | /* 59 | ** $Log: map094.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/10/24 12:19:33 matt 70 | ** changed directory structure 71 | ** 72 | ** Revision 1.5 2000/10/22 19:17:47 matt 73 | ** mapper cleanups galore 74 | ** 75 | ** Revision 1.4 2000/10/21 19:33:38 matt 76 | ** many more cleanups 77 | ** 78 | ** Revision 1.3 2000/08/16 02:50:11 matt 79 | ** random mapper 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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | { 46 | 99, /* mapper number */ 47 | "VS. System", /* mapper name */ 48 | map99_init, /* 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 | NULL, /* memory write structure */ 55 | NULL /* external sound device */ 56 | }; 57 | 58 | /* 59 | ** $Log: map099.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/10/24 12:19:33 matt 70 | ** changed directory structure 71 | ** 72 | ** Revision 1.6 2000/10/22 19:17:47 matt 73 | ** mapper cleanups galore 74 | ** 75 | ** Revision 1.5 2000/10/21 19:33:38 matt 76 | ** many more cleanups 77 | ** 78 | ** Revision 1.4 2000/10/10 13:58:17 matt 79 | ** stroustrup squeezing his way in the door 80 | ** 81 | ** Revision 1.3 2000/07/10 05:29:03 matt 82 | ** cleaned up some mirroring issues 83 | ** 84 | ** Revision 1.2 2000/07/06 02:48:43 matt 85 | ** clearly labelled structure members 86 | ** 87 | ** Revision 1.1 2000/07/05 05:05:18 matt 88 | ** initial revision 89 | ** 90 | */ 91 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 46 | { 47 | { 0x4100, 0x5FFF, map79_write }, /* ????? incorrect range ??? */ 48 | { -1, -1, NULL } 49 | }; 50 | 51 | mapintf_t map79_intf = 52 | { 53 | 79, /* mapper number */ 54 | "NINA-03/06", /* mapper name */ 55 | map79_init, /* init routine */ 56 | NULL, /* vblank callback */ 57 | NULL, /* hblank callback */ 58 | NULL, /* get state (snss) */ 59 | NULL, /* set state (snss) */ 60 | NULL, /* memory read structure */ 61 | map79_memwrite, /* memory write structure */ 62 | NULL /* external sound device */ 63 | }; 64 | 65 | /* 66 | ** $Log: map079.c,v $ 67 | ** Revision 1.2 2001/04/27 14:37:11 neil 68 | ** wheeee 69 | ** 70 | ** Revision 1.1 2001/04/27 12:54:40 neil 71 | ** blah 72 | ** 73 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 74 | ** initial 75 | ** 76 | ** Revision 1.1 2000/10/24 12:19:33 matt 77 | ** changed directory structure 78 | ** 79 | ** Revision 1.4 2000/10/22 19:17:47 matt 80 | ** mapper cleanups galore 81 | ** 82 | ** Revision 1.3 2000/10/21 19:33:38 matt 83 | ** many more 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/06 01:01:56 matt 89 | ** initial revision 90 | ** 91 | */ 92 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | 45 | static map_memwrite map66_memwrite[] = 46 | { 47 | { 0x8000, 0xFFFF, map66_write }, 48 | { -1, -1, NULL } 49 | }; 50 | 51 | mapintf_t map66_intf = 52 | { 53 | 66, /* mapper number */ 54 | "GNROM", /* mapper name */ 55 | map66_init, /* init routine */ 56 | NULL, /* vblank callback */ 57 | NULL, /* hblank callback */ 58 | NULL, /* get state (snss) */ 59 | NULL, /* set state (snss) */ 60 | NULL, /* memory read structure */ 61 | map66_memwrite, /* memory write structure */ 62 | NULL /* external sound device */ 63 | }; 64 | 65 | /* 66 | ** $Log: map066.c,v $ 67 | ** Revision 1.2 2001/04/27 14:37:11 neil 68 | ** wheeee 69 | ** 70 | ** Revision 1.1 2001/04/27 12:54:40 neil 71 | ** blah 72 | ** 73 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 74 | ** initial 75 | ** 76 | ** Revision 1.1 2000/10/24 12:19:33 matt 77 | ** changed directory structure 78 | ** 79 | ** Revision 1.5 2000/10/22 19:17:46 matt 80 | ** mapper cleanups galore 81 | ** 82 | ** Revision 1.4 2000/10/21 19:33:38 matt 83 | ** many more cleanups 84 | ** 85 | ** Revision 1.3 2000/08/16 02:50:11 matt 86 | ** random mapper cleanups 87 | ** 88 | ** Revision 1.2 2000/07/06 02:48:43 matt 89 | ** clearly labelled structure members 90 | ** 91 | ** Revision 1.1 2000/07/05 05:05:18 matt 92 | ** initial revision 93 | ** 94 | */ 95 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 45 | { 46 | { 0x8000, 0xFFFF, map11_write }, 47 | { -1, -1, NULL } 48 | }; 49 | 50 | mapintf_t map11_intf = 51 | { 52 | 11, /* mapper number */ 53 | "Color Dreams", /* mapper name */ 54 | map11_init, /* init routine */ 55 | NULL, /* vblank callback */ 56 | NULL, /* hblank callback */ 57 | NULL, /* get state (snss) */ 58 | NULL, /* set state (snss) */ 59 | NULL, /* memory read structure */ 60 | map11_memwrite, /* memory write structure */ 61 | NULL /* external sound device */ 62 | }; 63 | 64 | /* 65 | ** $Log: map011.c,v $ 66 | ** Revision 1.2 2001/04/27 14:37:11 neil 67 | ** wheeee 68 | ** 69 | ** Revision 1.1 2001/04/27 12:54:40 neil 70 | ** blah 71 | ** 72 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 73 | ** initial 74 | ** 75 | ** Revision 1.1 2000/10/24 12:19:33 matt 76 | ** changed directory structure 77 | ** 78 | ** Revision 1.5 2000/10/22 19:17:46 matt 79 | ** mapper cleanups galore 80 | ** 81 | ** Revision 1.4 2000/10/21 19:33:38 matt 82 | ** many more cleanups 83 | ** 84 | ** Revision 1.3 2000/08/16 02:50:11 matt 85 | ** random mapper cleanups 86 | ** 87 | ** Revision 1.2 2000/07/06 02:48:43 matt 88 | ** clearly labelled structure members 89 | ** 90 | ** Revision 1.1 2000/07/04 23:11:45 matt 91 | ** initial revision 92 | ** 93 | */ 94 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 46 | { 47 | { 0x8000, 0xFFFF, map8_write }, 48 | { -1, -1, NULL } 49 | }; 50 | 51 | mapintf_t map8_intf = 52 | { 53 | 8, /* mapper number */ 54 | "FFE F3xxx", /* mapper name */ 55 | map8_init, /* init routine */ 56 | NULL, /* vblank callback */ 57 | NULL, /* hblank callback */ 58 | NULL, /* get state (snss) */ 59 | NULL, /* set state (snss) */ 60 | NULL, /* memory read structure */ 61 | map8_memwrite, /* memory write structure */ 62 | NULL /* external sound device */ 63 | }; 64 | 65 | /* 66 | ** $Log: map008.c,v $ 67 | ** Revision 1.2 2001/04/27 14:37:11 neil 68 | ** wheeee 69 | ** 70 | ** Revision 1.1 2001/04/27 12:54:40 neil 71 | ** blah 72 | ** 73 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 74 | ** initial 75 | ** 76 | ** Revision 1.1 2000/10/24 12:19:32 matt 77 | ** changed directory structure 78 | ** 79 | ** Revision 1.5 2000/10/22 19:17:47 matt 80 | ** mapper cleanups galore 81 | ** 82 | ** Revision 1.4 2000/10/21 19:33:38 matt 83 | ** many more cleanups 84 | ** 85 | ** Revision 1.3 2000/08/16 02:50:11 matt 86 | ** random mapper cleanups 87 | ** 88 | ** Revision 1.2 2000/07/06 02:48:43 matt 89 | ** clearly labelled structure members 90 | ** 91 | ** Revision 1.1 2000/07/04 23:11:45 matt 92 | ** initial revision 93 | ** 94 | */ 95 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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) 32 | { 33 | mmc_bankrom(32, 0x8000, MMC_LASTBANK); 34 | } 35 | 36 | static void map231_write(uint32 address, uint8 value) 37 | { 38 | int bank, vbank; 39 | UNUSED(address); 40 | 41 | bank = ((value & 0x80) >> 5) | (value & 0x03); 42 | vbank = (value >> 4) & 0x07; 43 | 44 | mmc_bankrom(32, 0x8000, bank); 45 | mmc_bankvrom(8, 0x0000, vbank); 46 | } 47 | 48 | static map_memwrite map231_memwrite[] = 49 | { 50 | { 0x8000, 0xFFFF, map231_write }, 51 | { -1, -1, NULL } 52 | }; 53 | 54 | mapintf_t map231_intf = 55 | { 56 | 231, /* mapper number */ 57 | "NINA-07", /* mapper name */ 58 | map231_init, /* init routine */ 59 | NULL, /* vblank callback */ 60 | NULL, /* hblank callback */ 61 | NULL, /* get state (snss) */ 62 | NULL, /* set state (snss) */ 63 | NULL, /* memory read structure */ 64 | map231_memwrite, /* memory write structure */ 65 | NULL /* external sound device */ 66 | }; 67 | 68 | /* 69 | ** $Log: map231.c,v $ 70 | ** Revision 1.2 2001/04/27 14:37:11 neil 71 | ** wheeee 72 | ** 73 | ** Revision 1.1 2001/04/27 12:54:40 neil 74 | ** blah 75 | ** 76 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 77 | ** initial 78 | ** 79 | ** Revision 1.1 2000/10/24 12:19:33 matt 80 | ** changed directory structure 81 | ** 82 | ** Revision 1.4 2000/10/22 19:17:46 matt 83 | ** mapper cleanups galore 84 | ** 85 | ** Revision 1.3 2000/10/21 19:33:38 matt 86 | ** many more cleanups 87 | ** 88 | ** Revision 1.2 2000/08/16 02:50:11 matt 89 | ** random mapper cleanups 90 | ** 91 | ** Revision 1.1 2000/07/11 03:14:18 melanson 92 | ** Initial commit for mappers 16, 34, and 231 93 | ** 94 | ** 95 | */ 96 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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) mmc_bankvrom (8, 0x0000, 0x01); 44 | else mmc_bankvrom (8, 0x0000, 0x00); 45 | 46 | /* Done */ 47 | return; 48 | } 49 | 50 | static map_memwrite map87_memwrite [] = 51 | { 52 | { 0x6000, 0x7FFF, map87_write }, 53 | { -1, -1, NULL } 54 | }; 55 | 56 | mapintf_t map87_intf = 57 | { 58 | 87, /* Mapper number */ 59 | "16K VROM switch", /* Mapper name */ 60 | NULL, /* Initialization routine */ 61 | NULL, /* VBlank callback */ 62 | NULL, /* HBlank callback */ 63 | NULL, /* Get state (SNSS) */ 64 | NULL, /* Set state (SNSS) */ 65 | NULL, /* Memory read structure */ 66 | map87_memwrite, /* Memory write structure */ 67 | NULL /* External sound device */ 68 | }; 69 | 70 | /* 71 | ** $Log: map087.c,v $ 72 | ** Revision 1.2 2001/04/27 14:37:11 neil 73 | ** wheeee 74 | ** 75 | ** Revision 1.1 2001/04/27 12:54:40 neil 76 | ** blah 77 | ** 78 | ** Revision 1.1 2001/04/27 10:57:41 neil 79 | ** wheee 80 | ** 81 | ** Revision 1.1 2000/12/30 06:34:44 firebug 82 | ** Initial revision 83 | ** 84 | ** 85 | */ 86 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | 28 | #ifndef _NOFRENDO_H_ 29 | #define _NOFRENDO_H_ 30 | 31 | typedef enum 32 | { 33 | system_unknown, 34 | system_autodetect, 35 | system_nes, 36 | NUM_SUPPORTED_SYSTEMS 37 | } system_t; 38 | 39 | int nofrendo_main(int argc, char *argv[]); 40 | 41 | 42 | extern volatile int nofrendo_ticks; /* system timer ticks */ 43 | 44 | /* osd_main should end with a call to main_loop(). 45 | ** Pass filename = NULL if you want to start with the demo rom 46 | */ 47 | extern int main_loop(const char *filename, system_t type); 48 | 49 | /* These should not be called directly. Use the event interface */ 50 | extern void main_insert(const char *filename, system_t type); 51 | extern void main_eject(void); 52 | extern void main_quit(void); 53 | 54 | #endif /* !_NOFRENDO_H_ */ 55 | 56 | /* 57 | ** $Log: nofrendo.h,v $ 58 | ** Revision 1.2 2001/04/27 11:10:08 neil 59 | ** compile 60 | ** 61 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 62 | ** initial 63 | ** 64 | ** Revision 1.9 2000/11/25 20:26:05 matt 65 | ** removed fds "system" 66 | ** 67 | ** Revision 1.8 2000/11/20 13:22:12 matt 68 | ** standardized timer ISR, added nofrendo_ticks 69 | ** 70 | ** Revision 1.7 2000/11/01 14:15:35 matt 71 | ** multi-system event system, or whatever 72 | ** 73 | ** Revision 1.6 2000/10/25 13:42:02 matt 74 | ** strdup - giddyap! 75 | ** 76 | ** Revision 1.5 2000/10/25 01:23:08 matt 77 | ** basic system autodetection 78 | ** 79 | ** Revision 1.4 2000/10/23 15:52:04 matt 80 | ** better system handling 81 | ** 82 | ** Revision 1.3 2000/07/31 04:28:46 matt 83 | ** one million cleanups 84 | ** 85 | ** Revision 1.2 2000/07/27 01:16:36 matt 86 | ** sorted out the video problems 87 | ** 88 | ** Revision 1.1 2000/07/26 21:36:13 neil 89 | ** Big honkin' change -- see the mailing list 90 | ** 91 | ** 92 | */ 93 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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) 43 | { 44 | mmc_bankrom(32, 0x8000, 0); 45 | } 46 | 47 | static map_memwrite map7_memwrite[] = 48 | { 49 | { 0x8000, 0xFFFF, map7_write }, 50 | { -1, -1, NULL } 51 | }; 52 | 53 | mapintf_t map7_intf = 54 | { 55 | 7, /* mapper number */ 56 | "AOROM", /* mapper name */ 57 | map7_init, /* init 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 | map7_memwrite, /* memory write structure */ 64 | NULL /* external sound device */ 65 | }; 66 | 67 | /* 68 | ** $Log: map007.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:32 matt 79 | ** changed directory structure 80 | ** 81 | ** Revision 1.6 2000/10/22 19:17:46 matt 82 | ** mapper cleanups galore 83 | ** 84 | ** Revision 1.5 2000/10/22 15:03:13 matt 85 | ** simplified mirroring 86 | ** 87 | ** Revision 1.4 2000/10/21 19:33:38 matt 88 | ** many more cleanups 89 | ** 90 | ** Revision 1.3 2000/08/16 02:50:11 matt 91 | ** random mapper cleanups 92 | ** 93 | ** Revision 1.2 2000/07/06 02:48:43 matt 94 | ** clearly labelled structure members 95 | ** 96 | ** Revision 1.1 2000/07/04 23:11:45 matt 97 | ** initial revision 98 | ** 99 | */ 100 | -------------------------------------------------------------------------------- /lib/menu/src/charPixels.c: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "menu.h" 3 | #include "esp_system.h" 4 | #include "esp_event.h" 5 | #include "esp_event_loop.h" 6 | #include "esp_partition.h" 7 | #include "nvs_flash.h" 8 | #include "charData.c" 9 | #include 10 | #include "iconData.c" 11 | #include "pretty_effect.h" 12 | 13 | int yLineEnded; 14 | int charOff; 15 | int change; 16 | 17 | bool cpGetPixel(char cpChar, int cp1, int cp2) 18 | { 19 | return getPixel(cpChar, cp1, cp2); 20 | } 21 | 22 | //Load Rom list from flash partition to char array(lines), init some variables for printing rom list 23 | void initRomList() 24 | { 25 | FILE *romsFile = fopen(ROM_LIST, "r"); 26 | char line[64]; 27 | entryCount = -1; 28 | while (fgets(line, 64, romsFile) != NULL) 29 | { 30 | if (line[0] == '*' && line[1] == '#' && line[2] == '*') 31 | { 32 | break; 33 | } 34 | else 35 | { 36 | entryCount++; 37 | } 38 | } 39 | menuEntries = (MenuEntry *)malloc(entryCount * sizeof(MenuEntry)); 40 | rewind(romsFile); 41 | fgets(line, 64, romsFile); // Skip first line 42 | for (int i = 0; i < entryCount; i++) 43 | { 44 | menuEntries[i].entryNumber = -1; 45 | menuEntries[i].icon = 'E'; 46 | strcpy(menuEntries[i].name, "? "); 47 | strcpy(menuEntries[i].fileName, "? "); 48 | fscanf(romsFile, "%d.\t%c\t%[^\t]\t%[^\n\r]\n", 49 | &menuEntries[i].entryNumber, 50 | &menuEntries[i].icon, 51 | menuEntries[i].name, 52 | menuEntries[i].fileName); 53 | for (int j = FILENAME_LENGTH; j > 0; j--) 54 | { 55 | if (menuEntries[i].fileName[j] < ' ') { 56 | menuEntries[i].fileName[j] = '\0'; 57 | } 58 | } 59 | printf("Read entry number %d; icon %c; name %s; file %s\n", 60 | menuEntries[i].entryNumber, 61 | menuEntries[i].icon, 62 | menuEntries[i].name, 63 | menuEntries[i].fileName); 64 | } 65 | fclose(romsFile); 66 | printf("Read %d rom entries\n", entryCount); 67 | } 68 | 69 | //get depending on x/y value the actual char from lines array 70 | //depending on x/y/actChar return color/black if char value is true/false(charData.c) 71 | //depending on x/y/actChar read and return icon pixel color(iconData.c) 72 | int getCharPixel(int x, int y, int change, int choosen) 73 | { 74 | int page = choosen / 13; 75 | int line = ((y - 3) / 18) + 13 * page; 76 | int charNo = (x - 26) / 16; 77 | char actChar; 78 | 79 | if (line >= entryCount) 80 | { 81 | return 0x0000; 82 | } 83 | if (x >= 7 && x <= 22) 84 | { 85 | if (line == choosen) 86 | return getIconPixel(menuEntries[line].icon, x - 7, (y - 5) % 18, change); 87 | else 88 | return 0x0000; 89 | } 90 | actChar = menuEntries[line].name[charNo]; 91 | if (actChar < ' ') 92 | { 93 | return 0x0000; 94 | } 95 | if (getPixel(actChar, (x - 26) % 16, (y - 3) % 18) == 1) 96 | return 0x001F; 97 | return 0x0000; 98 | } 99 | 100 | void freeRL() 101 | { 102 | free(menuEntries); 103 | } -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | 57 | extern void mem_cleanup(void); 58 | extern void mem_checkblocks(void); 59 | extern void mem_checkleaks(void); 60 | 61 | extern bool mem_debug; 62 | 63 | #endif /* _MEMGUARD_H_ */ 64 | 65 | /* 66 | ** $Log: memguard.h,v $ 67 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 68 | ** initial 69 | ** 70 | ** Revision 1.11 2000/10/28 03:55:46 neil 71 | ** strdup redefined, previous definition here 72 | ** 73 | ** Revision 1.10 2000/10/25 13:41:29 matt 74 | ** added strdup 75 | ** 76 | ** Revision 1.9 2000/10/10 13:58:13 matt 77 | ** stroustrup squeezing his way in the door 78 | ** 79 | ** Revision 1.8 2000/07/31 04:28:46 matt 80 | ** one million cleanups 81 | ** 82 | ** Revision 1.7 2000/07/17 01:52:27 matt 83 | ** made sure last line of all source files is a newline 84 | ** 85 | ** Revision 1.6 2000/07/06 17:20:52 matt 86 | ** block manager space itself wasn't being freed - d'oh! 87 | ** 88 | ** Revision 1.5 2000/06/26 04:54:48 matt 89 | ** simplified and made more robust 90 | ** 91 | ** Revision 1.4 2000/06/09 15:12:25 matt 92 | ** initial revision 93 | ** 94 | */ 95 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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) 30 | { 31 | mmc_bankrom(32, 0x8000, MMC_LASTBANK); 32 | } 33 | 34 | static void map34_write(uint32 address, uint8 value) 35 | { 36 | if ((address & 0x8000) || (0x7FFD == address)) 37 | { 38 | mmc_bankrom(32, 0x8000, value); 39 | } 40 | else if (0x7FFE == address) 41 | { 42 | mmc_bankvrom(4, 0x0000, value); 43 | } 44 | else if (0x7FFF == address) 45 | { 46 | mmc_bankvrom(4, 0x1000, value); 47 | } 48 | } 49 | 50 | static map_memwrite map34_memwrite[] = 51 | { 52 | { 0x7FFD, 0xFFFF, map34_write }, 53 | { -1, -1, NULL } 54 | }; 55 | 56 | mapintf_t map34_intf = 57 | { 58 | 34, /* mapper number */ 59 | "Nina-1", /* mapper name */ 60 | map34_init, /* init routine */ 61 | NULL, /* vblank callback */ 62 | NULL, /* hblank callback */ 63 | NULL, /* get state (snss) */ 64 | NULL, /* set state (snss) */ 65 | NULL, /* memory read structure */ 66 | map34_memwrite, /* memory write structure */ 67 | NULL /* external sound device */ 68 | }; 69 | 70 | /* 71 | ** $Log: map034.c,v $ 72 | ** Revision 1.2 2001/04/27 14:37:11 neil 73 | ** wheeee 74 | ** 75 | ** Revision 1.1 2001/04/27 12:54:40 neil 76 | ** blah 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:19:33 matt 82 | ** changed directory structure 83 | ** 84 | ** Revision 1.5 2000/10/22 19:17:46 matt 85 | ** mapper cleanups galore 86 | ** 87 | ** Revision 1.4 2000/10/21 19:33:38 matt 88 | ** many more cleanups 89 | ** 90 | ** Revision 1.3 2000/07/11 05:03:49 matt 91 | ** value masking isn't necessary for the banking routines 92 | ** 93 | ** Revision 1.2 2000/07/11 03:35:08 bsittler 94 | ** Fixes to make mikes new mappers compile. 95 | ** 96 | ** Revision 1.1 2000/07/11 03:14:18 melanson 97 | ** Initial commit for mappers 16, 34, and 231 98 | ** 99 | ** 100 | */ 101 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | 66 | enum 67 | { 68 | INP_STATE_BREAK, 69 | INP_STATE_MAKE 70 | }; 71 | 72 | typedef struct nesinput_s 73 | { 74 | int type; 75 | int data; 76 | } nesinput_t; 77 | 78 | #define MAX_CONTROLLERS 32 79 | 80 | extern uint8 input_get(int type); 81 | extern void input_register(nesinput_t *input); 82 | extern void input_event(nesinput_t *input, int state, int value); 83 | extern void input_strobe(void); 84 | 85 | #endif /* _NESINPUT_H_ */ 86 | 87 | /* 88 | ** $Log: nesinput.h,v $ 89 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 90 | ** initial 91 | ** 92 | ** Revision 1.1 2000/10/24 12:20:28 matt 93 | ** changed directory structure 94 | ** 95 | ** Revision 1.6 2000/09/10 23:25:02 matt 96 | ** minor changes 97 | ** 98 | ** Revision 1.5 2000/07/17 01:52:29 matt 99 | ** made sure last line of all source files is a newline 100 | ** 101 | ** Revision 1.4 2000/06/09 15:12:26 matt 102 | ** initial revision 103 | ** 104 | */ 105 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 | 64 | extern int rom_checkmagic(const char *filename); 65 | extern rominfo_t *rom_load(const char *filename); 66 | extern void rom_free(rominfo_t **rominfo); 67 | extern char *rom_getinfo(rominfo_t *rominfo); 68 | extern void rom_savesram(rominfo_t *rominfo); 69 | 70 | 71 | #endif /* _NES_ROM_H_ */ 72 | 73 | /* 74 | ** $Log: nes_rom.h,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.2 2000/10/25 01:23:08 matt 82 | ** basic system autodetection 83 | ** 84 | ** Revision 1.1 2000/10/24 12:20:28 matt 85 | ** changed directory structure 86 | ** 87 | ** Revision 1.11 2000/10/22 15:01:29 matt 88 | ** irrelevant mirroring modes removed 89 | ** 90 | ** Revision 1.10 2000/10/17 03:22:38 matt 91 | ** cleaning up rom module 92 | ** 93 | ** Revision 1.9 2000/10/10 13:58:13 matt 94 | ** stroustrup squeezing his way in the door 95 | ** 96 | ** Revision 1.8 2000/10/10 13:03:54 matt 97 | ** Mr. Clean makes a guest appearance 98 | ** 99 | ** Revision 1.7 2000/07/25 02:20:58 matt 100 | ** cleanups 101 | ** 102 | ** Revision 1.6 2000/07/19 15:59:39 neil 103 | ** PATH_MAX, strncpy, snprintf, and strncat are our friends 104 | ** 105 | ** Revision 1.5 2000/07/17 01:52:27 matt 106 | ** made sure last line of all source files is a newline 107 | ** 108 | ** Revision 1.4 2000/06/09 15:12:25 matt 109 | ** initial revision 110 | ** 111 | */ 112 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 59 | { 60 | { 0x4040, 0x4092, fds_write }, 61 | { -1, -1, NULL } 62 | }; 63 | 64 | apuext_t fds_ext = 65 | { 66 | NULL, /* no init */ 67 | NULL, /* no shutdown */ 68 | fds_reset, 69 | fds_process, 70 | NULL, /* no reads */ 71 | fds_memwrite 72 | }; 73 | 74 | /* 75 | ** $Log: fds_snd.c,v $ 76 | ** Revision 1.2 2001/04/27 14:37:11 neil 77 | ** wheeee 78 | ** 79 | ** Revision 1.1 2001/04/27 12:54:40 neil 80 | ** blah 81 | ** 82 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 83 | ** initial 84 | ** 85 | ** Revision 1.1 2000/10/24 12:19:59 matt 86 | ** changed directory structure 87 | ** 88 | ** Revision 1.9 2000/10/11 12:13:15 matt 89 | ** quelled warnings 90 | ** 91 | ** Revision 1.8 2000/10/03 11:56:20 matt 92 | ** better support for optional sound ext routines 93 | ** 94 | ** Revision 1.7 2000/09/15 13:38:40 matt 95 | ** changes for optimized apu core 96 | ** 97 | ** Revision 1.6 2000/09/15 04:58:07 matt 98 | ** simplifying and optimizing APU core 99 | ** 100 | ** Revision 1.5 2000/07/30 04:32:59 matt 101 | ** no more apu_getcyclerate hack 102 | ** 103 | ** Revision 1.4 2000/07/17 01:52:30 matt 104 | ** made sure last line of all source files is a newline 105 | ** 106 | ** Revision 1.3 2000/07/03 02:18:53 matt 107 | ** much better external module exporting 108 | ** 109 | ** Revision 1.2 2000/06/20 04:06:16 matt 110 | ** migrated external sound definition to apu module 111 | ** 112 | ** Revision 1.1 2000/06/20 00:06:47 matt 113 | ** initial revision 114 | ** 115 | */ 116 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 70 | { 71 | { 0x8000, 0xFFFF, map32_write }, 72 | { -1, -1, NULL } 73 | }; 74 | 75 | mapintf_t map32_intf = 76 | { 77 | 32, /* mapper number */ 78 | "Irem G-101", /* mapper name */ 79 | NULL, /* init routine */ 80 | NULL, /* vblank callback */ 81 | NULL, /* hblank callback */ 82 | NULL, /* get state (snss) */ 83 | NULL, /* set state (snss) */ 84 | NULL, /* memory read structure */ 85 | map32_memwrite, /* memory write structure */ 86 | NULL /* external sound device */ 87 | }; 88 | 89 | /* 90 | ** $Log: map032.c,v $ 91 | ** Revision 1.2 2001/04/27 14:37:11 neil 92 | ** wheeee 93 | ** 94 | ** Revision 1.1 2001/04/27 12:54:40 neil 95 | ** blah 96 | ** 97 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 98 | ** initial 99 | ** 100 | ** Revision 1.1 2000/10/24 12:19:33 matt 101 | ** changed directory structure 102 | ** 103 | ** Revision 1.6 2000/10/22 19:17:46 matt 104 | ** mapper cleanups galore 105 | ** 106 | ** Revision 1.5 2000/10/22 15:03:13 matt 107 | ** simplified mirroring 108 | ** 109 | ** Revision 1.4 2000/10/21 19:33:38 matt 110 | ** many more cleanups 111 | ** 112 | ** Revision 1.3 2000/07/10 05:29:03 matt 113 | ** cleaned up some mirroring issues 114 | ** 115 | ** Revision 1.2 2000/07/06 02:48:43 matt 116 | ** clearly labelled structure members 117 | ** 118 | ** Revision 1.1 2000/07/06 01:01:56 matt 119 | ** initial revision 120 | ** 121 | */ 122 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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[] = 57 | { 58 | { 0x8000, 0xFFFF, map78_write }, 59 | { -1, -1, NULL } 60 | }; 61 | 62 | mapintf_t map78_intf = 63 | { 64 | 78, /* mapper number */ 65 | "Mapper 78", /* mapper name */ 66 | NULL, /* init routine */ 67 | NULL, /* vblank callback */ 68 | NULL, /* hblank callback */ 69 | NULL, /* get state (snss) */ 70 | NULL, /* set state (snss) */ 71 | NULL, /* memory read structure */ 72 | map78_memwrite, /* memory write structure */ 73 | NULL /* external sound device */ 74 | }; 75 | 76 | /* 77 | ** $Log: map078.c,v $ 78 | ** Revision 1.2 2001/04/27 14:37:11 neil 79 | ** wheeee 80 | ** 81 | ** Revision 1.1 2001/04/27 12:54:40 neil 82 | ** blah 83 | ** 84 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 85 | ** initial 86 | ** 87 | ** Revision 1.1 2000/10/24 12:19:33 matt 88 | ** changed directory structure 89 | ** 90 | ** Revision 1.7 2000/10/22 19:17:46 matt 91 | ** mapper cleanups galore 92 | ** 93 | ** Revision 1.6 2000/10/22 15:03:14 matt 94 | ** simplified mirroring 95 | ** 96 | ** Revision 1.5 2000/10/21 19:33:38 matt 97 | ** many more cleanups 98 | ** 99 | ** Revision 1.4 2000/08/16 02:50:11 matt 100 | ** random mapper cleanups 101 | ** 102 | ** Revision 1.3 2000/07/10 05:29:03 matt 103 | ** cleaned up some mirroring issues 104 | ** 105 | ** Revision 1.2 2000/07/06 02:48:43 matt 106 | ** clearly labelled structure members 107 | ** 108 | ** Revision 1.1 2000/07/06 01:01:56 matt 109 | ** initial revision 110 | ** 111 | */ 112 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 bool 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 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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 map11_intf; 40 | extern mapintf_t map15_intf; 41 | extern mapintf_t map16_intf; 42 | extern mapintf_t map18_intf; 43 | extern mapintf_t map19_intf; 44 | extern mapintf_t map21_intf; 45 | extern mapintf_t map22_intf; 46 | extern mapintf_t map23_intf; 47 | extern mapintf_t map24_intf; 48 | extern mapintf_t map25_intf; 49 | extern mapintf_t map32_intf; 50 | extern mapintf_t map33_intf; 51 | extern mapintf_t map34_intf; 52 | extern mapintf_t map40_intf; 53 | extern mapintf_t map64_intf; 54 | extern mapintf_t map65_intf; 55 | extern mapintf_t map66_intf; 56 | extern mapintf_t map70_intf; 57 | extern mapintf_t map75_intf; 58 | extern mapintf_t map78_intf; 59 | extern mapintf_t map79_intf; 60 | extern mapintf_t map85_intf; 61 | extern mapintf_t map94_intf; 62 | extern mapintf_t map99_intf; 63 | extern mapintf_t map231_intf; 64 | 65 | /* implemented mapper interfaces */ 66 | const mapintf_t *mappers[] = 67 | { 68 | &map0_intf, 69 | &map1_intf, 70 | &map2_intf, 71 | &map3_intf, 72 | &map4_intf, 73 | &map5_intf, 74 | &map7_intf, 75 | &map8_intf, 76 | &map9_intf, 77 | &map11_intf, 78 | &map15_intf, 79 | &map16_intf, 80 | &map18_intf, 81 | &map19_intf, 82 | &map21_intf, 83 | &map22_intf, 84 | &map23_intf, 85 | &map24_intf, 86 | &map25_intf, 87 | &map32_intf, 88 | &map33_intf, 89 | &map34_intf, 90 | &map40_intf, 91 | &map64_intf, 92 | &map65_intf, 93 | &map66_intf, 94 | &map70_intf, 95 | &map75_intf, 96 | &map78_intf, 97 | &map79_intf, 98 | &map85_intf, 99 | &map94_intf, 100 | &map99_intf, 101 | &map231_intf, 102 | NULL 103 | }; 104 | 105 | /* 106 | ** $Log: mmclist.c,v $ 107 | ** Revision 1.2 2001/04/27 14:37:11 neil 108 | ** wheeee 109 | ** 110 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 111 | ** initial 112 | ** 113 | ** Revision 1.1 2000/10/24 12:20:28 matt 114 | ** changed directory structure 115 | ** 116 | ** Revision 1.2 2000/10/10 13:05:30 matt 117 | ** Mr. Clean makes a guest appearance 118 | ** 119 | ** Revision 1.1 2000/07/31 04:27:39 matt 120 | ** initial revision 121 | ** 122 | */ 123 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map070.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 | ** map70.c 21 | ** 22 | ** mapper 70 interface 23 | ** $Id: map070.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* mapper 70: Arkanoid II, Kamen Rider Club, etc. */ 31 | /* ($8000-$FFFF) D6-D4 = switch $8000-$BFFF */ 32 | /* ($8000-$FFFF) D3-D0 = switch PPU $0000-$1FFF */ 33 | /* ($8000-$FFFF) D7 = switch mirroring */ 34 | static void map70_write(uint32 address, uint8 value) 35 | { 36 | UNUSED(address); 37 | 38 | mmc_bankrom(16, 0x8000, (value >> 4) & 0x07); 39 | mmc_bankvrom(8, 0x0000, value & 0x0F); 40 | 41 | /* Argh! FanWen used the 4-screen bit to determine 42 | ** whether the game uses D7 to switch between 43 | ** horizontal and vertical mirroring, or between 44 | ** one-screen mirroring from $2000 or $2400. 45 | */ 46 | if (mmc_getinfo()->flags & ROM_FLAG_FOURSCREEN) 47 | { 48 | if (value & 0x80) 49 | ppu_mirror(0, 0, 1, 1); /* horiz */ 50 | else 51 | ppu_mirror(0, 1, 0, 1); /* vert */ 52 | } 53 | else 54 | { 55 | int mirror = (value & 0x80) >> 7; 56 | ppu_mirror(mirror, mirror, mirror, mirror); 57 | } 58 | } 59 | 60 | static map_memwrite map70_memwrite[] = 61 | { 62 | { 0x8000, 0xFFFF, map70_write }, 63 | { -1, -1, NULL } 64 | }; 65 | 66 | mapintf_t map70_intf = 67 | { 68 | 70, /* mapper number */ 69 | "Mapper 70", /* mapper name */ 70 | NULL, /* init routine */ 71 | NULL, /* vblank callback */ 72 | NULL, /* hblank callback */ 73 | NULL, /* get state (snss) */ 74 | NULL, /* set state (snss) */ 75 | NULL, /* memory read structure */ 76 | map70_memwrite, /* memory write structure */ 77 | NULL /* external sound device */ 78 | }; 79 | 80 | /* 81 | ** $Log: map070.c,v $ 82 | ** Revision 1.2 2001/04/27 14:37:11 neil 83 | ** wheeee 84 | ** 85 | ** Revision 1.1 2001/04/27 12:54:40 neil 86 | ** blah 87 | ** 88 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 89 | ** initial 90 | ** 91 | ** Revision 1.1 2000/10/24 12:19:33 matt 92 | ** changed directory structure 93 | ** 94 | ** Revision 1.7 2000/10/22 19:17:46 matt 95 | ** mapper cleanups galore 96 | ** 97 | ** Revision 1.6 2000/10/22 15:03:13 matt 98 | ** simplified mirroring 99 | ** 100 | ** Revision 1.5 2000/10/21 19:33:38 matt 101 | ** many more cleanups 102 | ** 103 | ** Revision 1.4 2000/08/16 02:50:11 matt 104 | ** random mapper cleanups 105 | ** 106 | ** Revision 1.3 2000/07/10 05:29:03 matt 107 | ** cleaned up some mirroring issues 108 | ** 109 | ** Revision 1.2 2000/07/06 02:48:43 matt 110 | ** clearly labelled structure members 111 | ** 112 | ** Revision 1.1 2000/07/06 01:01:56 matt 113 | ** initial revision 114 | ** 115 | */ 116 | -------------------------------------------------------------------------------- /lib/nofrendo/src/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) ppu_mirror(0, 0, 1, 1); 73 | else ppu_mirror(0, 1, 0, 1); 74 | 75 | /* Done */ 76 | return; 77 | } 78 | 79 | static map_memwrite map229_memwrite [] = 80 | { 81 | { 0x8000, 0xFFFF, map229_write }, 82 | { -1, -1, NULL } 83 | }; 84 | 85 | mapintf_t map229_intf = 86 | { 87 | 229, /* Mapper number */ 88 | "31 in 1 (bootleg)", /* Mapper name */ 89 | map229_init, /* Initialization routine */ 90 | NULL, /* VBlank callback */ 91 | NULL, /* HBlank callback */ 92 | NULL, /* Get state (SNSS) */ 93 | NULL, /* Set state (SNSS) */ 94 | NULL, /* Memory read structure */ 95 | map229_memwrite, /* Memory write structure */ 96 | NULL /* External sound device */ 97 | }; 98 | 99 | /* 100 | ** $Log: map229.c,v $ 101 | ** Revision 1.2 2001/04/27 14:37:11 neil 102 | ** wheeee 103 | ** 104 | ** Revision 1.1 2001/04/27 12:54:40 neil 105 | ** blah 106 | ** 107 | ** Revision 1.1 2001/04/27 10:57:41 neil 108 | ** wheee 109 | ** 110 | ** Revision 1.1 2000/12/30 06:34:31 firebug 111 | ** Initial revision 112 | ** 113 | ** 114 | */ 115 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map075.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 | ** map75.c 21 | ** 22 | ** mapper 75 interface 23 | ** $Id: map075.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | static uint8 latch[2]; 32 | static uint8 hibits; 33 | 34 | /* mapper 75: Konami VRC1 */ 35 | static void map75_write(uint32 address, uint8 value) 36 | { 37 | switch ((address & 0xF000) >> 12) 38 | { 39 | case 0x8: 40 | mmc_bankrom(8, 0x8000, value); 41 | break; 42 | 43 | case 0x9: 44 | hibits = (value & 0x06); 45 | 46 | mmc_bankvrom(4, 0x0000, ((hibits & 0x02) << 3) | latch[0]); 47 | mmc_bankvrom(4, 0x1000, ((hibits & 0x04) << 2) | latch[1]); 48 | 49 | if (value & 1) 50 | ppu_mirror(0, 1, 0, 1); /* vert */ 51 | else 52 | ppu_mirror(0, 0, 1, 1); /* horiz */ 53 | 54 | break; 55 | 56 | case 0xA: 57 | mmc_bankrom(8, 0xA000, value); 58 | break; 59 | 60 | case 0xC: 61 | mmc_bankrom(8, 0xC000, value); 62 | break; 63 | 64 | case 0xE: 65 | latch[0] = (value & 0x0F); 66 | mmc_bankvrom(4, 0x0000, ((hibits & 0x02) << 3) | latch[0]); 67 | break; 68 | 69 | case 0xF: 70 | latch[1] = (value & 0x0F); 71 | mmc_bankvrom(4, 0x1000, ((hibits & 0x04) << 2) | latch[1]); 72 | break; 73 | 74 | default: 75 | break; 76 | } 77 | } 78 | 79 | static map_memwrite map75_memwrite[] = 80 | { 81 | { 0x8000, 0xFFFF, map75_write }, 82 | { -1, -1, NULL } 83 | }; 84 | 85 | mapintf_t map75_intf = 86 | { 87 | 75, /* mapper number */ 88 | "Konami VRC1", /* mapper name */ 89 | NULL, /* init routine */ 90 | NULL, /* vblank callback */ 91 | NULL, /* hblank callback */ 92 | NULL, /* get state (snss) */ 93 | NULL, /* set state (snss) */ 94 | NULL, /* memory read structure */ 95 | map75_memwrite, /* memory write structure */ 96 | NULL /* external sound device */ 97 | }; 98 | 99 | /* 100 | ** $Log: map075.c,v $ 101 | ** Revision 1.2 2001/04/27 14:37:11 neil 102 | ** wheeee 103 | ** 104 | ** Revision 1.1 2001/04/27 12:54:40 neil 105 | ** blah 106 | ** 107 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 108 | ** initial 109 | ** 110 | ** Revision 1.1 2000/10/24 12:19:33 matt 111 | ** changed directory structure 112 | ** 113 | ** Revision 1.6 2000/10/22 19:17:46 matt 114 | ** mapper cleanups galore 115 | ** 116 | ** Revision 1.5 2000/10/22 15:03:14 matt 117 | ** simplified mirroring 118 | ** 119 | ** Revision 1.4 2000/10/21 19:33:38 matt 120 | ** many more cleanups 121 | ** 122 | ** Revision 1.3 2000/07/10 05:29:03 matt 123 | ** cleaned up some mirroring issues 124 | ** 125 | ** Revision 1.2 2000/07/06 02:48:43 matt 126 | ** clearly labelled structure members 127 | ** 128 | ** Revision 1.1 2000/07/06 01:01:56 matt 129 | ** initial revision 130 | ** 131 | */ 132 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map160.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 | ** map160.c 21 | ** 22 | ** mapper 160 interface 23 | ** $Id: map160.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | static struct 32 | { 33 | bool enabled, expired; 34 | int counter; 35 | int latch_c005, latch_c003; 36 | } irq; 37 | 38 | static void map160_write(uint32 address, uint8 value) 39 | { 40 | if (address >= 0x8000 && address <= 0x8003) 41 | { 42 | mmc_bankrom(8, 0x8000 + 0x2000 * (address & 3), value); 43 | } 44 | else if (address >= 0x9000 && address <= 0x9007) 45 | { 46 | mmc_bankvrom(1, 0x400 * (address & 7), value); 47 | } 48 | else if (0xC002 == address) 49 | { 50 | irq.enabled = false; 51 | irq.latch_c005 = irq.latch_c003; 52 | } 53 | else if (0xC003 == address) 54 | { 55 | if (false == irq.expired) 56 | { 57 | irq.counter = value; 58 | } 59 | else 60 | { 61 | irq.expired = false; 62 | irq.enabled = true; 63 | irq.counter = irq.latch_c005; 64 | } 65 | } 66 | else if (0xC005 == address) 67 | { 68 | irq.latch_c005 = value; 69 | irq.counter = value; 70 | } 71 | #ifdef NOFRENDO_DEBUG 72 | else 73 | { 74 | log_printf("mapper 160: untrapped write $%02X to $%04X\n", value, address); 75 | } 76 | #endif /* NOFRENDO_DEBUG */ 77 | } 78 | 79 | static void map160_hblank(int vblank) 80 | { 81 | if (!vblank) 82 | { 83 | if (ppu_enabled() && irq.enabled) 84 | { 85 | if (0 == irq.counter && false == irq.expired) 86 | { 87 | irq.expired = true; 88 | nes_irq(); 89 | } 90 | else 91 | { 92 | irq.counter--; 93 | } 94 | } 95 | } 96 | } 97 | 98 | static void map160_init(void) 99 | { 100 | irq.enabled = false; 101 | irq.expired = false; 102 | irq.counter = 0; 103 | irq.latch_c003 = irq.latch_c005 = 0; 104 | } 105 | 106 | static map_memwrite map160_memwrite[] = 107 | { 108 | { 0x8000, 0xFFFF, map160_write }, 109 | { -1, -1, NULL } 110 | }; 111 | 112 | mapintf_t map160_intf = 113 | { 114 | 160, /* mapper number */ 115 | "Aladdin (pirate)", /* mapper name */ 116 | map160_init, /* init routine */ 117 | NULL, /* vblank callback */ 118 | map160_hblank, /* hblank callback */ 119 | NULL, /* get state (snss) */ 120 | NULL, /* set state (snss) */ 121 | NULL, /* memory read structure */ 122 | map160_memwrite, /* memory write structure */ 123 | NULL /* external sound device */ 124 | }; 125 | 126 | /* 127 | ** $Log: map160.c,v $ 128 | ** Revision 1.2 2001/04/27 14:37:11 neil 129 | ** wheeee 130 | ** 131 | ** Revision 1.1 2001/04/27 12:54:40 neil 132 | ** blah 133 | ** 134 | ** Revision 1.1 2001/04/27 10:57:41 neil 135 | ** wheee 136 | ** 137 | ** Revision 1.1 2000/12/27 04:24:46 matt 138 | ** initial revision 139 | ** 140 | */ 141 | -------------------------------------------------------------------------------- /lib/nofrendo/src/pcx.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 | ** pcx.c 21 | ** 22 | ** PCX format screen-saving routines 23 | ** $Id: pcx.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | /* Save a PCX snapshot from a given NES bitmap */ 33 | int pcx_write(char *filename, bitmap_t *bmp, rgb_t *pal) 34 | { 35 | FILE *fp; 36 | pcxheader_t header; 37 | int i, line; 38 | int width, height, x_min, y_min; 39 | 40 | ASSERT(bmp); 41 | 42 | width = bmp->width; 43 | height = bmp->height; 44 | x_min = 0; 45 | y_min = 0; 46 | 47 | fp = fopen(filename, "wb"); 48 | if (NULL == fp) 49 | return -1; 50 | 51 | /* Fill in the header nonsense */ 52 | memset(&header, 0, sizeof(header)); 53 | 54 | header.Manufacturer = 10; 55 | header.Version = 5; 56 | header.Encoding = 1; 57 | header.BitsPerPixel = 8; 58 | header.Xmin = x_min; 59 | header.Ymin = y_min; 60 | header.Xmax = width - 1; 61 | header.Ymax = height - 1; 62 | header.NPlanes = 1; 63 | header.BytesPerLine = width; 64 | header.PaletteInfo = 1; 65 | header.HscreenSize = width - 1; 66 | header.VscreenSize = height - 1; 67 | 68 | fwrite(&header, 1, sizeof(header), fp); 69 | 70 | /* RLE encoding */ 71 | for (line = 0; line < height; line++) 72 | { 73 | uint8 last, *mem; 74 | int xpos = 0; 75 | 76 | mem = bmp->line[line + y_min] + x_min; 77 | 78 | while (xpos < width) 79 | { 80 | int rle_count = 0; 81 | 82 | do 83 | { 84 | last = *mem++; 85 | xpos++; 86 | rle_count++; 87 | } 88 | while (*mem == last && xpos < width && rle_count < 0x3F); 89 | 90 | if (rle_count > 1 || 0xC0 == (last & 0xC0)) 91 | { 92 | fputc(0xC0 | rle_count, fp); 93 | fputc(last, fp); 94 | } 95 | else 96 | { 97 | fputc(last, fp); 98 | } 99 | } 100 | } 101 | 102 | /* Write palette */ 103 | fputc(0x0C, fp); /* $0C signifies 256 color palette */ 104 | for (i = 0; i < 256; i++) 105 | { 106 | fputc(pal[i].r, fp); 107 | fputc(pal[i].g, fp); 108 | fputc(pal[i].b, fp); 109 | } 110 | 111 | /* We're done! */ 112 | fclose(fp); 113 | return 0; 114 | } 115 | 116 | /* 117 | ** $Log: pcx.c,v $ 118 | ** Revision 1.2 2001/04/27 14:37:11 neil 119 | ** wheeee 120 | ** 121 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 122 | ** initial 123 | ** 124 | ** Revision 1.8 2000/11/06 05:17:48 matt 125 | ** better! 126 | ** 127 | ** Revision 1.7 2000/11/05 16:37:18 matt 128 | ** rolled rgb.h into bitmap.h 129 | ** 130 | ** Revision 1.6 2000/07/17 01:52:27 matt 131 | ** made sure last line of all source files is a newline 132 | ** 133 | ** Revision 1.5 2000/06/26 04:55:13 matt 134 | ** changed routine name, big whoop 135 | ** 136 | ** Revision 1.4 2000/06/09 15:12:25 matt 137 | ** initial revision 138 | ** 139 | */ 140 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map065.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 | ** map65.c 21 | ** 22 | ** mapper 65 interface 23 | ** $Id: map065.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static struct 31 | { 32 | int counter; 33 | bool enabled; 34 | int cycles; 35 | uint8 low, high; 36 | } irq; 37 | 38 | static void map65_init(void) 39 | { 40 | irq.counter = 0; 41 | irq.enabled = false; 42 | irq.low = irq.high = 0; 43 | irq.cycles = 0; 44 | } 45 | 46 | /* TODO: shouldn't there be some kind of HBlank callback??? */ 47 | 48 | /* mapper 65: Irem H-3001*/ 49 | static void map65_write(uint32 address, uint8 value) 50 | { 51 | int range = address & 0xF000; 52 | int reg = address & 7; 53 | 54 | switch (range) 55 | { 56 | case 0x8000: 57 | case 0xA000: 58 | case 0xC000: 59 | mmc_bankrom(8, range, value); 60 | break; 61 | 62 | case 0xB000: 63 | mmc_bankvrom(1, reg << 10, value); 64 | break; 65 | 66 | case 0x9000: 67 | switch (reg) 68 | { 69 | case 4: 70 | irq.enabled = (value & 0x01) ? false : true; 71 | break; 72 | 73 | case 5: 74 | irq.high = value; 75 | irq.cycles = (irq.high << 8) | irq.low; 76 | irq.counter = (uint8)(irq.cycles / 128); 77 | break; 78 | 79 | case 6: 80 | irq.low = value; 81 | irq.cycles = (irq.high << 8) | irq.low; 82 | irq.counter = (uint8)(irq.cycles / 128); 83 | break; 84 | 85 | default: 86 | break; 87 | } 88 | break; 89 | 90 | default: 91 | break; 92 | } 93 | } 94 | 95 | static map_memwrite map65_memwrite[] = 96 | { 97 | { 0x8000, 0xFFFF, map65_write }, 98 | { -1, -1, NULL } 99 | }; 100 | 101 | mapintf_t map65_intf = 102 | { 103 | 65, /* mapper number */ 104 | "Irem H-3001", /* mapper name */ 105 | map65_init, /* init routine */ 106 | NULL, /* vblank callback */ 107 | NULL, /* hblank callback */ 108 | NULL, /* get state (snss) */ 109 | NULL, /* set state (snss) */ 110 | NULL, /* memory read structure */ 111 | map65_memwrite, /* memory write structure */ 112 | NULL /* external sound device */ 113 | }; 114 | 115 | /* 116 | ** $Log: map065.c,v $ 117 | ** Revision 1.2 2001/04/27 14:37:11 neil 118 | ** wheeee 119 | ** 120 | ** Revision 1.1 2001/04/27 12:54:40 neil 121 | ** blah 122 | ** 123 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 124 | ** initial 125 | ** 126 | ** Revision 1.1 2000/10/24 12:19:33 matt 127 | ** changed directory structure 128 | ** 129 | ** Revision 1.5 2000/10/22 19:17:46 matt 130 | ** mapper cleanups galore 131 | ** 132 | ** Revision 1.4 2000/10/21 19:33:38 matt 133 | ** many more cleanups 134 | ** 135 | ** Revision 1.3 2000/10/10 13:58:17 matt 136 | ** stroustrup squeezing his way in the door 137 | ** 138 | ** Revision 1.2 2000/07/06 02:48:43 matt 139 | ** clearly labelled structure members 140 | ** 141 | ** Revision 1.1 2000/07/06 01:01:56 matt 142 | ** initial revision 143 | ** 144 | */ 145 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map033.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 | ** map33.c 21 | ** 22 | ** mapper 33 interface 23 | ** $Id: map033.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* mapper 33: Taito TC0190*/ 31 | static void map33_write(uint32 address, uint8 value) 32 | { 33 | int page = (address >> 13) & 3; 34 | int reg = address & 3; 35 | 36 | switch (page) 37 | { 38 | case 0: /* $800X */ 39 | switch (reg) 40 | { 41 | case 0: 42 | mmc_bankrom(8, 0x8000, value); 43 | break; 44 | 45 | case 1: 46 | mmc_bankrom(8, 0xA000, value); 47 | break; 48 | 49 | case 2: 50 | mmc_bankvrom(2, 0x0000, value); 51 | break; 52 | 53 | case 3: 54 | mmc_bankvrom(2, 0x0800, value); 55 | break; 56 | } 57 | break; 58 | 59 | case 1: /* $A00X */ 60 | { 61 | int loc = 0x1000 + (reg << 10); 62 | mmc_bankvrom(1, loc, value); 63 | } 64 | break; 65 | 66 | case 2: /* $C00X */ 67 | case 3: /* $E00X */ 68 | switch (reg) 69 | { 70 | case 0: 71 | /* irqs maybe ? */ 72 | //break; 73 | 74 | case 1: 75 | /* this doesn't seem to work just right */ 76 | if (value & 1) 77 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 78 | else 79 | ppu_mirror(0, 1, 0, 1); 80 | break; 81 | 82 | default: 83 | break; 84 | } 85 | break; 86 | } 87 | } 88 | 89 | 90 | static map_memwrite map33_memwrite[] = 91 | { 92 | { 0x8000, 0xFFFF, map33_write }, 93 | { -1, -1, NULL } 94 | }; 95 | 96 | mapintf_t map33_intf = 97 | { 98 | 33, /* mapper number */ 99 | "Taito TC0190", /* mapper name */ 100 | NULL, /* init routine */ 101 | NULL, /* vblank callback */ 102 | NULL, /* hblank callback */ 103 | NULL, /* get state (snss) */ 104 | NULL, /* set state (snss) */ 105 | NULL, /* memory read structure */ 106 | map33_memwrite, /* memory write structure */ 107 | NULL /* external sound device */ 108 | }; 109 | 110 | /* 111 | ** $Log: map033.c,v $ 112 | ** Revision 1.2 2001/04/27 14:37:11 neil 113 | ** wheeee 114 | ** 115 | ** Revision 1.1 2001/04/27 12:54:40 neil 116 | ** blah 117 | ** 118 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 119 | ** initial 120 | ** 121 | ** Revision 1.1 2000/10/24 12:19:33 matt 122 | ** changed directory structure 123 | ** 124 | ** Revision 1.7 2000/10/22 19:17:46 matt 125 | ** mapper cleanups galore 126 | ** 127 | ** Revision 1.6 2000/10/22 15:03:13 matt 128 | ** simplified mirroring 129 | ** 130 | ** Revision 1.5 2000/10/21 19:33:38 matt 131 | ** many more cleanups 132 | ** 133 | ** Revision 1.4 2000/07/15 23:52:19 matt 134 | ** rounded out a bunch more mapper interfaces 135 | ** 136 | ** Revision 1.3 2000/07/10 05:29:03 matt 137 | ** cleaned up some mirroring issues 138 | ** 139 | ** Revision 1.2 2000/07/06 02:48:43 matt 140 | ** clearly labelled structure members 141 | ** 142 | ** Revision 1.1 2000/07/06 01:01:56 matt 143 | ** initial revision 144 | ** 145 | */ 146 | -------------------------------------------------------------------------------- /lib/nofrendo/src/gui.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.h 21 | ** 22 | ** GUI defines / prototypes 23 | ** $Id: gui.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _GUI_H_ 27 | #define _GUI_H_ 28 | 29 | /* GUI colors - the last 64 of a 256-color palette */ 30 | 31 | #define GUI_FIRSTENTRY 192 32 | 33 | enum 34 | { 35 | GUI_BLACK = GUI_FIRSTENTRY, 36 | GUI_DKGRAY, 37 | GUI_GRAY, 38 | GUI_LTGRAY, 39 | GUI_WHITE, 40 | GUI_RED, 41 | GUI_GREEN, 42 | GUI_BLUE, 43 | GUI_YELLOW, 44 | GUI_ORANGE, 45 | GUI_PURPLE, 46 | GUI_TEAL, 47 | GUI_DKGREEN, 48 | GUI_DKBLUE, 49 | GUI_LASTENTRY 50 | }; 51 | 52 | #define GUI_TOTALCOLORS (GUI_LASTENTRY - GUI_FIRSTENTRY) 53 | 54 | /* TODO: bleh */ 55 | #include 56 | extern rgb_t gui_pal[GUI_TOTALCOLORS]; 57 | 58 | #define MAX_MSG_LENGTH 256 59 | 60 | typedef struct message_s 61 | { 62 | int ttl; 63 | char text[MAX_MSG_LENGTH]; 64 | uint8 color; 65 | } message_t; 66 | 67 | extern void gui_tick(int ticks); 68 | extern void gui_setrefresh(int frequency); 69 | 70 | extern void gui_sendmsg(int color, char *format, ...); 71 | 72 | extern int gui_init(void); 73 | extern void gui_shutdown(void); 74 | 75 | extern void gui_frame(bool draw); 76 | 77 | extern void gui_togglefps(void); 78 | extern void gui_togglegui(void); 79 | extern void gui_togglewave(void); 80 | extern void gui_togglepattern(void); 81 | extern void gui_toggleoam(void); 82 | 83 | extern void gui_decpatterncol(void); 84 | extern void gui_incpatterncol(void); 85 | 86 | extern void gui_savesnap(void); 87 | extern void gui_togglesprites(void); 88 | extern void gui_togglefs(void); 89 | extern void gui_displayinfo(); 90 | extern void gui_toggle_chan(int chan); 91 | extern void gui_setfilter(int filter_type); 92 | 93 | 94 | #endif /* _GUI_H_ */ 95 | 96 | /* 97 | ** $Log: gui.h,v $ 98 | ** Revision 1.2 2001/04/27 14:37:11 neil 99 | ** wheeee 100 | ** 101 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 102 | ** initial 103 | ** 104 | ** Revision 1.17 2000/11/05 16:37:18 matt 105 | ** rolled rgb.h into bitmap.h 106 | ** 107 | ** Revision 1.16 2000/10/27 12:57:49 matt 108 | ** fixed pcx snapshots 109 | ** 110 | ** Revision 1.15 2000/10/23 17:50:47 matt 111 | ** adding fds support 112 | ** 113 | ** Revision 1.14 2000/10/23 15:52:04 matt 114 | ** better system handling 115 | ** 116 | ** Revision 1.13 2000/10/22 19:15:39 matt 117 | ** more sane timer ISR / autoframeskip 118 | ** 119 | ** Revision 1.12 2000/10/10 13:58:13 matt 120 | ** stroustrup squeezing his way in the door 121 | ** 122 | ** Revision 1.11 2000/10/10 13:03:53 matt 123 | ** Mr. Clean makes a guest appearance 124 | ** 125 | ** Revision 1.10 2000/10/08 17:59:12 matt 126 | ** gui_ticks is volatile 127 | ** 128 | ** Revision 1.9 2000/07/31 04:28:46 matt 129 | ** one million cleanups 130 | ** 131 | ** Revision 1.8 2000/07/25 02:20:47 matt 132 | ** moved gui palette filth here, for the time being 133 | ** 134 | ** Revision 1.7 2000/07/23 15:16:25 matt 135 | ** moved non-osd code here 136 | ** 137 | ** Revision 1.6 2000/07/17 01:52:27 matt 138 | ** made sure last line of all source files is a newline 139 | ** 140 | ** Revision 1.5 2000/07/09 03:39:33 matt 141 | ** small gui_frame cleanup 142 | ** 143 | ** Revision 1.4 2000/06/09 15:12:25 matt 144 | ** initial revision 145 | ** 146 | */ 147 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map015.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 | ** map15.c 21 | ** 22 | ** mapper 15 interface 23 | ** $Id: map015.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* mapper 15: Contra 100-in-1 */ 31 | static void map15_write(uint32 address, uint8 value) 32 | { 33 | int bank = value & 0x3F; 34 | uint8 swap = (value & 0x80) >> 7; 35 | 36 | switch (address & 0x3) 37 | { 38 | case 0: 39 | mmc_bankrom(8, 0x8000, (bank << 1) + swap); 40 | mmc_bankrom(8, 0xA000, (bank << 1) + (swap ^ 1)); 41 | mmc_bankrom(8, 0xC000, ((bank + 1) << 1) + swap); 42 | mmc_bankrom(8, 0xE000, ((bank + 1) << 1) + (swap ^ 1)); 43 | 44 | if (value & 0x40) 45 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 46 | else 47 | ppu_mirror(0, 1, 0, 1); /* vertical */ 48 | break; 49 | 50 | case 1: 51 | mmc_bankrom(8, 0xC000, (bank << 1) + swap); 52 | mmc_bankrom(8, 0xE000, (bank << 1) + (swap ^ 1)); 53 | break; 54 | 55 | case 2: 56 | if (swap) 57 | { 58 | mmc_bankrom(8, 0x8000, (bank << 1) + 1); 59 | mmc_bankrom(8, 0xA000, (bank << 1) + 1); 60 | mmc_bankrom(8, 0xC000, (bank << 1) + 1); 61 | mmc_bankrom(8, 0xE000, (bank << 1) + 1); 62 | } 63 | else 64 | { 65 | mmc_bankrom(8, 0x8000, (bank << 1)); 66 | mmc_bankrom(8, 0xA000, (bank << 1)); 67 | mmc_bankrom(8, 0xC000, (bank << 1)); 68 | mmc_bankrom(8, 0xE000, (bank << 1)); 69 | } 70 | break; 71 | 72 | case 3: 73 | mmc_bankrom(8, 0xC000, (bank << 1) + swap); 74 | mmc_bankrom(8, 0xE000, (bank << 1) + (swap ^ 1)); 75 | 76 | if (value & 0x40) 77 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 78 | else 79 | ppu_mirror(0, 1, 0, 1); /* vertical */ 80 | break; 81 | 82 | default: 83 | break; 84 | } 85 | } 86 | 87 | static void map15_init(void) 88 | { 89 | mmc_bankrom(32, 0x8000, 0); 90 | } 91 | 92 | static map_memwrite map15_memwrite[] = 93 | { 94 | { 0x8000, 0xFFFF, map15_write }, 95 | { -1, -1, NULL } 96 | }; 97 | 98 | mapintf_t map15_intf = 99 | { 100 | 15, /* mapper number */ 101 | "Contra 100-in-1", /* mapper name */ 102 | map15_init, /* init routine */ 103 | NULL, /* vblank callback */ 104 | NULL, /* hblank callback */ 105 | NULL, /* get state (snss) */ 106 | NULL, /* set state (snss) */ 107 | NULL, /* memory read structure */ 108 | map15_memwrite, /* memory write structure */ 109 | NULL /* external sound device */ 110 | }; 111 | 112 | /* 113 | ** $Log: map015.c,v $ 114 | ** Revision 1.2 2001/04/27 14:37:11 neil 115 | ** wheeee 116 | ** 117 | ** Revision 1.1 2001/04/27 12:54:40 neil 118 | ** blah 119 | ** 120 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 121 | ** initial 122 | ** 123 | ** Revision 1.1 2000/10/24 12:19:33 matt 124 | ** changed directory structure 125 | ** 126 | ** Revision 1.6 2000/10/22 19:17:46 matt 127 | ** mapper cleanups galore 128 | ** 129 | ** Revision 1.5 2000/10/22 15:03:13 matt 130 | ** simplified mirroring 131 | ** 132 | ** Revision 1.4 2000/10/21 19:33:38 matt 133 | ** many more cleanups 134 | ** 135 | ** Revision 1.3 2000/07/10 05:29:03 matt 136 | ** cleaned up some mirroring issues 137 | ** 138 | ** Revision 1.2 2000/07/06 02:48:43 matt 139 | ** clearly labelled structure members 140 | ** 141 | ** Revision 1.1 2000/07/05 05:05:18 matt 142 | ** initial revision 143 | ** 144 | */ 145 | -------------------------------------------------------------------------------- /lib/nofrendo/src/event.h: -------------------------------------------------------------------------------- 1 | /* vim: set tabstop=3 expandtab: 2 | ** 3 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 4 | ** 5 | ** 6 | ** This program is free software; you can redistribute it and/or 7 | ** modify it under the terms of version 2 of the GNU Library General 8 | ** Public License as published by the Free Software Foundation. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | ** Library General Public License for more details. To obtain a 14 | ** copy of the GNU Library General Public License, write to the Free 15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | ** 17 | ** Any permitted reproduction of these routines, in whole or in part, 18 | ** must bear this legend. 19 | ** 20 | ** 21 | ** event.h 22 | ** 23 | ** OS-independent event handling 24 | ** $Id: event.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 25 | */ 26 | 27 | #ifndef _EVENT_H_ 28 | #define _EVENT_H_ 29 | 30 | #include 31 | 32 | enum 33 | { 34 | event_none = 0, 35 | event_quit, 36 | event_insert, 37 | event_eject, 38 | event_togglepause, 39 | event_soft_reset, 40 | event_hard_reset, 41 | event_snapshot, 42 | event_toggle_frameskip, 43 | /* saves */ 44 | event_state_save, 45 | event_state_load, 46 | event_state_slot_0, 47 | event_state_slot_1, 48 | event_state_slot_2, 49 | event_state_slot_3, 50 | event_state_slot_4, 51 | event_state_slot_5, 52 | event_state_slot_6, 53 | event_state_slot_7, 54 | event_state_slot_8, 55 | event_state_slot_9, 56 | /* GUI */ 57 | event_gui_toggle_oam, 58 | event_gui_toggle_wave, 59 | event_gui_toggle_pattern, 60 | event_gui_pattern_color_up, 61 | event_gui_pattern_color_down, 62 | event_gui_toggle_fps, 63 | event_gui_display_info, 64 | event_gui_toggle, 65 | /* sound */ 66 | event_toggle_channel_0, 67 | event_toggle_channel_1, 68 | event_toggle_channel_2, 69 | event_toggle_channel_3, 70 | event_toggle_channel_4, 71 | event_toggle_channel_5, 72 | event_set_filter_0, 73 | event_set_filter_1, 74 | event_set_filter_2, 75 | /* picture */ 76 | event_toggle_sprites, 77 | event_palette_hue_up, 78 | event_palette_hue_down, 79 | event_palette_tint_up, 80 | event_palette_tint_down, 81 | event_palette_set_default, 82 | event_palette_set_shady, 83 | /* joypad 1 */ 84 | event_joypad1_a, 85 | event_joypad1_b, 86 | event_joypad1_start, 87 | event_joypad1_select, 88 | event_joypad1_up, 89 | event_joypad1_down, 90 | event_joypad1_left, 91 | event_joypad1_right, 92 | /* joypad 2 */ 93 | event_joypad2_a, 94 | event_joypad2_b, 95 | event_joypad2_start, 96 | event_joypad2_select, 97 | event_joypad2_up, 98 | event_joypad2_down, 99 | event_joypad2_left, 100 | event_joypad2_right, 101 | /* NSF control */ 102 | event_songup, 103 | event_songdown, 104 | event_startsong, 105 | /* OS specific */ 106 | event_osd_1, 107 | event_osd_2, 108 | event_osd_3, 109 | event_osd_4, 110 | event_osd_5, 111 | event_osd_6, 112 | event_osd_7, 113 | event_osd_8, 114 | event_osd_9, 115 | /* last */ 116 | event_last 117 | }; 118 | 119 | typedef void (*event_t)(int code); 120 | 121 | extern void event_init(void); 122 | extern void event_set(int index, event_t handler); 123 | extern event_t event_get(int index); 124 | extern void event_set_system(system_t type); 125 | 126 | #endif /* !_EVENT_H_ */ 127 | 128 | /* 129 | ** $Log: event.h,v $ 130 | ** Revision 1.2 2001/04/27 14:37:11 neil 131 | ** wheeee 132 | ** 133 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 134 | ** initial 135 | ** 136 | ** Revision 1.6 2000/11/01 14:15:35 matt 137 | ** multi-system event system, or whatever 138 | ** 139 | ** Revision 1.5 2000/10/10 13:03:54 matt 140 | ** Mr. Clean makes a guest appearance 141 | ** 142 | ** Revision 1.4 2000/07/31 04:28:46 matt 143 | ** one million cleanups 144 | ** 145 | ** Revision 1.3 2000/07/26 21:36:13 neil 146 | ** Big honkin' change -- see the mailing list 147 | ** 148 | ** Revision 1.2 2000/07/21 04:27:40 matt 149 | ** don't mind me... 150 | ** 151 | ** Revision 1.1 2000/07/21 04:26:38 matt 152 | ** initial revision 153 | ** 154 | */ 155 | -------------------------------------------------------------------------------- /lib/nofrendo/src/nes/nes_mmc.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_mmc.h 21 | ** 22 | ** NES Memory Management Controller (mapper) defines / prototypes 23 | ** $Id: nes_mmc.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _NES_MMC_H_ 27 | #define _NES_MMC_H_ 28 | 29 | #include 30 | #include 31 | 32 | #define MMC_LASTBANK -1 33 | 34 | typedef struct 35 | { 36 | uint32 min_range, max_range; 37 | uint8 (*read_func)(uint32 address); 38 | } map_memread; 39 | 40 | typedef struct 41 | { 42 | uint32 min_range, max_range; 43 | void (*write_func)(uint32 address, uint8 value); 44 | } map_memwrite; 45 | 46 | 47 | typedef struct mapintf_s 48 | { 49 | int number; 50 | char *name; 51 | void (*init)(void); 52 | void (*vblank)(void); 53 | void (*hblank)(int vblank); 54 | void (*get_state)(SnssMapperBlock *state); 55 | void (*set_state)(SnssMapperBlock *state); 56 | map_memread *mem_read; 57 | map_memwrite *mem_write; 58 | apuext_t *sound_ext; 59 | } mapintf_t; 60 | 61 | 62 | #include 63 | typedef struct mmc_s 64 | { 65 | mapintf_t *intf; 66 | rominfo_t *cart; /* link it back to the cart */ 67 | } mmc_t; 68 | 69 | extern rominfo_t *mmc_getinfo(void); 70 | 71 | extern void mmc_bankvrom(int size, uint32 address, int bank); 72 | extern void mmc_bankrom(int size, uint32 address, int bank); 73 | 74 | /* Prototypes */ 75 | extern mmc_t *mmc_create(rominfo_t *rominfo); 76 | extern void mmc_destroy(mmc_t **nes_mmc); 77 | 78 | extern void mmc_getcontext(mmc_t *dest_mmc); 79 | extern void mmc_setcontext(mmc_t *src_mmc); 80 | 81 | extern bool mmc_peek(int map_num); 82 | 83 | extern void mmc_reset(void); 84 | 85 | #endif /* _NES_MMC_H_ */ 86 | 87 | /* 88 | ** $Log: nes_mmc.h,v $ 89 | ** Revision 1.2 2001/04/27 14:37:11 neil 90 | ** wheeee 91 | ** 92 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 93 | ** initial 94 | ** 95 | ** Revision 1.2 2000/10/25 00:23:16 matt 96 | ** makefiles updated for new directory structure 97 | ** 98 | ** Revision 1.1 2000/10/24 12:20:28 matt 99 | ** changed directory structure 100 | ** 101 | ** Revision 1.18 2000/10/22 19:17:24 matt 102 | ** mapper cleanups galore 103 | ** 104 | ** Revision 1.17 2000/10/21 19:26:59 matt 105 | ** many more cleanups 106 | ** 107 | ** Revision 1.16 2000/10/17 03:22:58 matt 108 | ** cleaning up rom module 109 | ** 110 | ** Revision 1.15 2000/10/10 13:58:15 matt 111 | ** stroustrup squeezing his way in the door 112 | ** 113 | ** Revision 1.14 2000/07/31 04:27:59 matt 114 | ** one million cleanups 115 | ** 116 | ** Revision 1.13 2000/07/25 02:25:53 matt 117 | ** safer xxx_destroy calls 118 | ** 119 | ** Revision 1.12 2000/07/17 01:52:28 matt 120 | ** made sure last line of all source files is a newline 121 | ** 122 | ** Revision 1.11 2000/07/15 23:50:03 matt 123 | ** migrated state get/set from nes_mmc.c to state.c 124 | ** 125 | ** Revision 1.10 2000/07/11 02:38:01 matt 126 | ** added setcontext() routine 127 | ** 128 | ** Revision 1.9 2000/07/10 05:27:41 matt 129 | ** cleaned up mapper-specific callbacks 130 | ** 131 | ** Revision 1.8 2000/07/04 23:12:58 matt 132 | ** brand spankin' new mapper interface implemented 133 | ** 134 | ** Revision 1.7 2000/07/04 04:56:36 matt 135 | ** modifications for new SNSS 136 | ** 137 | ** Revision 1.6 2000/06/29 14:17:18 matt 138 | ** uses snsslib now 139 | ** 140 | ** Revision 1.5 2000/06/29 03:09:24 matt 141 | ** modified to support new snss code 142 | ** 143 | ** Revision 1.4 2000/06/09 15:12:26 matt 144 | ** initial revision 145 | ** 146 | */ 147 | -------------------------------------------------------------------------------- /Case design/readme.md: -------------------------------------------------------------------------------- 1 | ### ESP32Boy Case 2 | 3 | This case was designed around reusing a PSX controller to lower the overall part count. Also, using a PSX controller means only 6 wires to connect. 4 | 5 | Please note, this is still being designed and your results may vary. To date I have confirmed a good fit with the PSX controller board and buttons. I also have test-fitted the screen and moved the SD card slot accordingly. That being said, right now I still have yet to assemble the whole thing and put internal mounting locations, so in the spirit of a true prototype anything else is going to be done with duct tape and bubble gum until I can finalize things a bit better. 6 | 7 | 8 | ### Parts used 9 | 10 | 1) ESP32 WRover, I use "Geekworm ESP32 WROVER PCB Development Board with 8MB PSRAM" 11 | 2) ili9341-based screen. I'm using "HiLetgo ILI9341 2.8 SPI TFT LCD Display Touch Panel 240X320 with PCB 5V/3.3V STM32" -- If you get a different size screen then you'll have to adjust the model in OpenSCAD (and have fun with that, it's organized but still could use a lot more organization still) -- If you get another 2.8" display make sure that the SD card is in the same relative location otherwise you'll have to adjust the SD card offsets in the model, which is not as hard as changing the size of the whole display. 12 | 3) Class D Amp, I use "Mini PAM8403 Digital Power Amplifier Board 23W Class D 2.5-5V USB Power" 13 | 4) TP4056 battery charger board, I use "Icstation TP4056 Micro USB 5V 1A 18650 Lithium Battery Charger Board" 14 | 5) 3.7v Lithium Ion battery, I use "MakerFocus 4pcs 3.7V Lithium Rechargable Battery, 802540 3.7V 1000mAh Battery " 15 | 6) 8ohm 0.5watt speaker. I use "uxcell 4 Pcs 0.5W 8 Ohm 26mm Internal Magnet Electronic Toy Speaker Amplifier" 16 | 17 | ### Printing 18 | 19 | I recommend printing with a layer height of 0.15 or smaller to ensure a better surface finish and also to make sure there are many layers supporting the screw holes. If you are using a material that supports post-print annealing (e.g. bake it in the oven) that would improve rigidity but is hopefully not necessary. I recommend printing with a 0.4 nozzle or smaller because those screw holes and gaps for the controller buttons are really small, otherwise expect that you will need to do post-print adjustments. Final note is that if you're using Cura pay attention to the advanced option "Slicing tolerance" which can make a big difference in how well things will fit. I've been trying both "inclusive" and "middle" but your mileage may vary. 20 | 21 | ### Assembling 22 | 23 | This really depends on if you want to experiment or make everything permanent. For experimentation use female/female prototype wiring and solder male headers to everything. This makes it much easier to confirm everything works. 24 | 25 | Remove all the screws from the PSX controller and carefully dismantle it without breaking any wires going to the shoulder buttons boards. I haven't decided where to put them in the final design but hopefully it will involve using the original wiring for simplicity. Save all the screws and innards as they will be reused. 26 | 27 | You will most likely need to desolder the PSX controller wiring plug from the board and solder new wires, but that's your preference. Note the wiring order on the board since it's all color-coded. More information about the PSX pinout is in the main readme in the top directory of this project. 28 | 29 | Once you're fairly sure that everything is working, mount the LCD screen with very small and very short screws. 30 | 31 | Carefully place the controller buttons into the case, noting that there are notches that prevent you from putting buttons in the wrong places. When assembling the D-Pad area make sure to place the X cross correctly. 32 | 33 | Mount the ESP32 to the back of the LCD screen using heavy-duty 2-sided tape, with the main part of the ESP32 module (the silver part) facing down. This makes it easier to solder to the board. 34 | 35 | Connect the battery to the charger board and then connect the ground of the charger board to the ESP32 ground. However note that the charger board outputs too much voltage for the ESP32, which you can drop using a simple zener diode going from the VCC of the charger board's output to the 3.3 VCC pin on the ESP32. 36 | 37 | Connect the speaker output, VCC, and ground pins to the Class D amp board and then connect the speaker. Mount the speaker using hot glue to the case between the controller supports. Be careful not to damage the membrane of the speaker! 38 | 39 | The LCD, PSX, and SD connections are provded in the main readme. See the excel wiring pinout excel file for helpful diagrams of all these locations. 40 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map040.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 | ** map40.c 21 | ** 22 | ** mapper 40 interface 23 | ** $Id: map040.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define MAP40_IRQ_PERIOD (4096 / 113.666666) 33 | 34 | static struct 35 | { 36 | int enabled, counter; 37 | } irq; 38 | 39 | /* mapper 40: SMB 2j (hack) */ 40 | static void map40_init(void) 41 | { 42 | mmc_bankrom(8, 0x6000, 6); 43 | mmc_bankrom(8, 0x8000, 4); 44 | mmc_bankrom(8, 0xA000, 5); 45 | mmc_bankrom(8, 0xE000, 7); 46 | 47 | irq.enabled = false; 48 | irq.counter = (int) MAP40_IRQ_PERIOD; 49 | } 50 | 51 | static void map40_hblank(int vblank) 52 | { 53 | UNUSED(vblank); 54 | 55 | if (irq.enabled && irq.counter) 56 | { 57 | irq.counter--; 58 | if (0 == irq.counter) 59 | { 60 | nes_irq(); 61 | irq.enabled = false; 62 | } 63 | } 64 | } 65 | 66 | static void map40_write(uint32 address, uint8 value) 67 | { 68 | int range = (address >> 13) - 4; 69 | 70 | switch (range) 71 | { 72 | case 0: /* 0x8000-0x9FFF */ 73 | irq.enabled = false; 74 | irq.counter = (int) MAP40_IRQ_PERIOD; 75 | break; 76 | 77 | case 1: /* 0xA000-0xBFFF */ 78 | irq.enabled = true; 79 | break; 80 | 81 | case 3: /* 0xE000-0xFFFF */ 82 | mmc_bankrom(8, 0xC000, value & 7); 83 | break; 84 | 85 | default: 86 | break; 87 | } 88 | } 89 | 90 | static void map40_getstate(SnssMapperBlock *state) 91 | { 92 | state->extraData.mapper40.irqCounter = irq.counter; 93 | state->extraData.mapper40.irqCounterEnabled = irq.enabled; 94 | } 95 | 96 | static void map40_setstate(SnssMapperBlock *state) 97 | { 98 | irq.counter = state->extraData.mapper40.irqCounter; 99 | irq.enabled = state->extraData.mapper40.irqCounterEnabled; 100 | } 101 | 102 | static map_memwrite map40_memwrite[] = 103 | { 104 | { 0x8000, 0xFFFF, map40_write }, 105 | { -1, -1, NULL } 106 | }; 107 | 108 | mapintf_t map40_intf = 109 | { 110 | 40, /* mapper number */ 111 | "SMB 2j (pirate)", /* mapper name */ 112 | map40_init, /* init routine */ 113 | NULL, /* vblank callback */ 114 | map40_hblank, /* hblank callback */ 115 | map40_getstate, /* get state (snss) */ 116 | map40_setstate, /* set state (snss) */ 117 | NULL, /* memory read structure */ 118 | map40_memwrite, /* memory write structure */ 119 | NULL /* external sound device */ 120 | }; 121 | 122 | /* 123 | ** $Log: map040.c,v $ 124 | ** Revision 1.2 2001/04/27 14:37:11 neil 125 | ** wheeee 126 | ** 127 | ** Revision 1.1 2001/04/27 12:54:40 neil 128 | ** blah 129 | ** 130 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 131 | ** initial 132 | ** 133 | ** Revision 1.1 2000/10/24 12:19:33 matt 134 | ** changed directory structure 135 | ** 136 | ** Revision 1.9 2000/10/23 15:53:27 matt 137 | ** suppressed warnings 138 | ** 139 | ** Revision 1.8 2000/10/22 19:17:46 matt 140 | ** mapper cleanups galore 141 | ** 142 | ** Revision 1.7 2000/10/21 19:33:38 matt 143 | ** many more cleanups 144 | ** 145 | ** Revision 1.6 2000/10/10 13:58:17 matt 146 | ** stroustrup squeezing his way in the door 147 | ** 148 | ** Revision 1.5 2000/08/16 02:50:11 matt 149 | ** random mapper cleanups 150 | ** 151 | ** Revision 1.4 2000/07/15 23:52:19 matt 152 | ** rounded out a bunch more mapper interfaces 153 | ** 154 | ** Revision 1.3 2000/07/10 13:51:25 matt 155 | ** using generic nes_irq() routine now 156 | ** 157 | ** Revision 1.2 2000/07/06 02:48:43 matt 158 | ** clearly labelled structure members 159 | ** 160 | ** Revision 1.1 2000/07/05 05:05:18 matt 161 | ** initial revision 162 | ** 163 | */ 164 | -------------------------------------------------------------------------------- /lib/nofrendo/src/log.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 | ** log.c 21 | ** 22 | ** Error logging functions 23 | ** $Id: log.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | //static FILE *errorlog = NULL; 34 | static int (*log_func)(const char *string) = NULL; 35 | 36 | /* first up: debug versions of calls */ 37 | #ifdef NOFRENDO_DEBUG 38 | int log_init(void) 39 | { 40 | // errorlog = fopen("errorlog.txt", "wt"); 41 | // if (NULL == errorlog) 42 | // return (-1); 43 | 44 | return 0; 45 | } 46 | 47 | void log_shutdown(void) 48 | { 49 | /* Snoop around for unallocated blocks */ 50 | mem_checkblocks(); 51 | mem_checkleaks(); 52 | mem_cleanup(); 53 | 54 | // if (NULL != errorlog) 55 | // fclose(errorlog); 56 | } 57 | 58 | int log_print(const char *string) 59 | { 60 | /* if we have a custom logging function, use that */ 61 | if (NULL != log_func) 62 | log_func(string); 63 | 64 | /* Log it to disk, as well */ 65 | // fputs(string, errorlog); 66 | // printf("%s\n", string); 67 | 68 | return 0; 69 | } 70 | 71 | int log_printf(const char *format, ... ) 72 | { 73 | /* don't allocate on stack every call */ 74 | static char buffer[1024 + 1]; 75 | va_list arg; 76 | 77 | va_start(arg, format); 78 | 79 | if (NULL != log_func) 80 | { 81 | vsprintf(buffer, format, arg); 82 | log_func(buffer); 83 | } 84 | 85 | // vfprintf(errorlog, format, arg); 86 | va_end(arg); 87 | 88 | return 0; /* should be number of chars written */ 89 | } 90 | 91 | #else /* !NOFRENDO_DEBUG */ 92 | 93 | int log_init(void) 94 | { 95 | return 0; 96 | } 97 | 98 | void log_shutdown(void) 99 | { 100 | } 101 | 102 | int log_print(const char *string) 103 | { 104 | UNUSED(string); 105 | 106 | return 0; 107 | } 108 | 109 | int log_printf(const char *format, ... ) 110 | { 111 | UNUSED(format); 112 | 113 | return 0; /* should be number of chars written */ 114 | } 115 | #endif /* !NOFRENDO_DEBUG */ 116 | 117 | void log_chain_logfunc(int (*func)(const char *string)) 118 | { 119 | log_func = func; 120 | } 121 | 122 | void log_assert(int expr, int line, const char *file, char *msg) 123 | { 124 | if (expr) 125 | return; 126 | 127 | if (NULL != msg) 128 | log_printf("ASSERT: line %d of %s, %s\n", line, file, msg); 129 | else 130 | log_printf("ASSERT: line %d of %s\n", line, file); 131 | 132 | asm("break.n 1"); 133 | // exit(-1); 134 | } 135 | 136 | 137 | /* 138 | ** $Log: log.c,v $ 139 | ** Revision 1.2 2001/04/27 14:37:11 neil 140 | ** wheeee 141 | ** 142 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 143 | ** initial 144 | ** 145 | ** Revision 1.14 2000/11/13 00:56:17 matt 146 | ** doesn't look as nasty now 147 | ** 148 | ** Revision 1.13 2000/11/06 02:15:07 matt 149 | ** more robust logging routines 150 | ** 151 | ** Revision 1.12 2000/10/15 13:28:12 matt 152 | ** need stdlib.h for exit() 153 | ** 154 | ** Revision 1.11 2000/10/10 13:13:13 matt 155 | ** dumb bug in log_chain_logfunc 156 | ** 157 | ** Revision 1.10 2000/10/10 13:03:54 matt 158 | ** Mr. Clean makes a guest appearance 159 | ** 160 | ** Revision 1.9 2000/08/28 01:47:10 matt 161 | ** quelled fricking compiler complaints 162 | ** 163 | ** Revision 1.8 2000/07/31 04:28:46 matt 164 | ** one million cleanups 165 | ** 166 | ** Revision 1.7 2000/07/17 01:52:27 matt 167 | ** made sure last line of all source files is a newline 168 | ** 169 | ** Revision 1.6 2000/07/06 17:20:52 matt 170 | ** block manager space itself wasn't being freed - d'oh! 171 | ** 172 | ** Revision 1.5 2000/06/26 04:55:33 matt 173 | ** minor change 174 | ** 175 | ** Revision 1.4 2000/06/09 15:12:25 matt 176 | ** initial revision 177 | ** 178 | */ 179 | -------------------------------------------------------------------------------- /lib/nofrendo/src/bitmap.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 | ** bitmap.c 21 | ** 22 | ** Bitmap object manipulation routines 23 | ** $Id: bitmap.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | void bmp_clear(const bitmap_t *bitmap, uint8 color) 32 | { 33 | memset(bitmap->data, color, bitmap->pitch * bitmap->height); 34 | } 35 | 36 | static bitmap_t *_make_bitmap(uint8 *data_addr, bool hw, int width, 37 | int height, int pitch, int overdraw) 38 | { 39 | bitmap_t *bitmap; 40 | int i; 41 | 42 | /* quick safety check */ 43 | if (NULL == data_addr) 44 | return NULL; 45 | 46 | /* Make sure to add in space for line pointers */ 47 | bitmap = malloc(sizeof(bitmap_t) + (sizeof(uint8 *) * height)); 48 | if (NULL == bitmap) 49 | return NULL; 50 | 51 | bitmap->hardware = hw; 52 | bitmap->height = height; 53 | bitmap->width = width; 54 | bitmap->data = data_addr; 55 | bitmap->pitch = pitch + (overdraw * 2); 56 | 57 | /* Set up line pointers */ 58 | /* we want to make some 32-bit aligned adjustment 59 | ** if we haven't been given a hardware bitmap 60 | */ 61 | if (false == bitmap->hardware) 62 | { 63 | bitmap->pitch = (bitmap->pitch + 3) & ~3; 64 | bitmap->line[0] = (uint8 *) (((uint32) bitmap->data + overdraw + 3) & ~3); 65 | } 66 | else 67 | { 68 | bitmap->line[0] = bitmap->data + overdraw; 69 | } 70 | 71 | for (i = 1; i < height; i++) 72 | bitmap->line[i] = bitmap->line[i - 1] + bitmap->pitch; 73 | 74 | return bitmap; 75 | } 76 | 77 | /* Allocate and initialize a bitmap structure */ 78 | bitmap_t *bmp_create(int width, int height, int overdraw) 79 | { 80 | uint8 *addr; 81 | int pitch; 82 | 83 | pitch = width + (overdraw * 2); /* left and right */ 84 | addr = malloc((pitch * height) + 3); /* add max 32-bit aligned adjustment */ 85 | if (NULL == addr) 86 | return NULL; 87 | 88 | return _make_bitmap(addr, false, width, height, width, overdraw); 89 | } 90 | 91 | /* allocate and initialize a hardware bitmap */ 92 | bitmap_t *bmp_createhw(uint8 *addr, int width, int height, int pitch) 93 | { 94 | return _make_bitmap(addr, true, width, height, pitch, 0); /* zero overdraw */ 95 | } 96 | 97 | /* Deallocate space for a bitmap structure */ 98 | void bmp_destroy(bitmap_t **bitmap) 99 | { 100 | if (*bitmap) 101 | { 102 | if ((*bitmap)->data && false == (*bitmap)->hardware) 103 | free((*bitmap)->data); 104 | free(*bitmap); 105 | *bitmap = NULL; 106 | } 107 | } 108 | 109 | /* 110 | ** $Log: bitmap.c,v $ 111 | ** Revision 1.2 2001/04/27 14:37:11 neil 112 | ** wheeee 113 | ** 114 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 115 | ** initial 116 | ** 117 | ** Revision 1.16 2000/11/05 16:37:18 matt 118 | ** rolled rgb.h into bitmap.h 119 | ** 120 | ** Revision 1.15 2000/10/10 13:58:13 matt 121 | ** stroustrup squeezing his way in the door 122 | ** 123 | ** Revision 1.14 2000/09/18 02:06:48 matt 124 | ** -pedantic is your friend 125 | ** 126 | ** Revision 1.13 2000/08/13 13:16:30 matt 127 | ** bugfix for alignment adjustment 128 | ** 129 | ** Revision 1.12 2000/07/24 04:31:43 matt 130 | ** pitch/data area on non-hw bitmaps get padded to 32-bit boundaries 131 | ** 132 | ** Revision 1.11 2000/07/17 01:52:27 matt 133 | ** made sure last line of all source files is a newline 134 | ** 135 | ** Revision 1.10 2000/07/09 14:43:01 matt 136 | ** pitch is now configurable for bmp_createhw() 137 | ** 138 | ** Revision 1.9 2000/07/06 17:55:57 matt 139 | ** two big bugs fixed 140 | ** 141 | ** Revision 1.8 2000/07/06 17:38:11 matt 142 | ** replaced missing string.h include 143 | ** 144 | ** Revision 1.7 2000/07/06 16:46:57 matt 145 | ** added bmp_clear() routine 146 | ** 147 | ** Revision 1.6 2000/06/26 04:56:24 matt 148 | ** minor cleanup 149 | ** 150 | ** Revision 1.5 2000/06/09 15:12:25 matt 151 | ** initial revision 152 | ** 153 | */ 154 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map046.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 | ** map046.c 21 | ** 22 | ** Mapper #46 (Pelican Game Station) 23 | ** Implementation by Firebug 24 | ** Mapper information courtesy of Kevin Horton 25 | ** $Id: map046.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 | static uint8 prg_low_bank; 36 | static uint8 chr_low_bank; 37 | static uint8 prg_high_bank; 38 | static uint8 chr_high_bank; 39 | 40 | /*************************************************/ 41 | /* Set banks from the combined register values */ 42 | /*************************************************/ 43 | static void map46_set_banks (void) 44 | { 45 | /* Set the PRG and CHR pages */ 46 | mmc_bankrom (32, 0x8000, (prg_high_bank << 1) | (prg_low_bank)); 47 | mmc_bankvrom (8, 0x0000, (chr_high_bank << 3) | (chr_low_bank)); 48 | 49 | /* Done */ 50 | return; 51 | } 52 | 53 | /*********************************************************/ 54 | /* Mapper #46: Pelican Game Station (aka Rumble Station) */ 55 | /*********************************************************/ 56 | static void map46_init (void) 57 | { 58 | /* High bank switch register is set to zero on reset */ 59 | prg_high_bank = 0x00; 60 | chr_high_bank = 0x00; 61 | map46_set_banks (); 62 | 63 | /* Done */ 64 | return; 65 | } 66 | 67 | /******************************************/ 68 | /* Mapper #46 write handler ($6000-$FFFF) */ 69 | /******************************************/ 70 | static void map46_write (uint32 address, uint8 value) 71 | { 72 | /* $8000-$FFFF: D6-D4 = lower three bits of CHR bank */ 73 | /* D0 = low bit of PRG bank */ 74 | /* $6000-$7FFF: D7-D4 = high four bits of CHR bank */ 75 | /* D3-D0 = high four bits of PRG bank */ 76 | if (address & 0x8000) 77 | { 78 | prg_low_bank = value & 0x01; 79 | chr_low_bank = (value >> 4) & 0x07; 80 | map46_set_banks (); 81 | } 82 | else 83 | { 84 | prg_high_bank = value & 0x0F; 85 | chr_high_bank = (value >> 4) & 0x0F; 86 | map46_set_banks (); 87 | } 88 | 89 | /* Done */ 90 | return; 91 | } 92 | 93 | /****************************************************/ 94 | /* Shove extra mapper information into a SNSS block */ 95 | /****************************************************/ 96 | static void map46_setstate (SnssMapperBlock *state) 97 | { 98 | /* TODO: Store SNSS information */ 99 | UNUSED (state); 100 | 101 | /* Done */ 102 | return; 103 | } 104 | 105 | /*****************************************************/ 106 | /* Pull extra mapper information out of a SNSS block */ 107 | /*****************************************************/ 108 | static void map46_getstate (SnssMapperBlock *state) 109 | { 110 | /* TODO: Retrieve SNSS information */ 111 | UNUSED (state); 112 | 113 | /* Done */ 114 | return; 115 | } 116 | 117 | static map_memwrite map46_memwrite [] = 118 | { 119 | { 0x6000, 0xFFFF, map46_write }, 120 | { -1, -1, NULL } 121 | }; 122 | 123 | mapintf_t map46_intf = 124 | { 125 | 46, /* Mapper number */ 126 | "Pelican Game Station", /* Mapper name */ 127 | map46_init, /* Initialization routine */ 128 | NULL, /* VBlank callback */ 129 | NULL, /* HBlank callback */ 130 | map46_getstate, /* Get state (SNSS) */ 131 | map46_setstate, /* Set state (SNSS) */ 132 | NULL, /* Memory read structure */ 133 | map46_memwrite, /* Memory write structure */ 134 | NULL /* External sound device */ 135 | }; 136 | 137 | /* 138 | ** $Log: map046.c,v $ 139 | ** Revision 1.2 2001/04/27 14:37:11 neil 140 | ** wheeee 141 | ** 142 | ** Revision 1.1 2001/04/27 12:54:40 neil 143 | ** blah 144 | ** 145 | ** Revision 1.1 2001/04/27 10:57:41 neil 146 | ** wheee 147 | ** 148 | ** Revision 1.1 2000/12/27 19:23:05 firebug 149 | ** initial revision 150 | ** 151 | ** 152 | */ 153 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map019.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 | ** map19.c 21 | ** 22 | ** mapper 19 interface 23 | ** $Id: map019.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* TODO: shouldn't there be an h-blank IRQ handler??? */ 31 | 32 | /* Special mirroring macro for mapper 19 */ 33 | #define N_BANK1(table, value) \ 34 | { \ 35 | if ((value) < 0xE0) \ 36 | ppu_setpage(1, (table) + 8, &mmc_getinfo()->vrom[((value) % (mmc_getinfo()->vrom_banks * 8)) << 10] - (0x2000 + ((table) << 10))); \ 37 | else \ 38 | ppu_setpage(1, (table) + 8, &mmc_getinfo()->vram[((value) & 7) << 10] - (0x2000 + ((table) << 10))); \ 39 | ppu_mirrorhipages(); \ 40 | } 41 | 42 | static struct 43 | { 44 | int counter, enabled; 45 | } irq; 46 | 47 | static void map19_init(void) 48 | { 49 | irq.counter = irq.enabled = 0; 50 | } 51 | 52 | /* mapper 19: Namcot 106 */ 53 | static void map19_write(uint32 address, uint8 value) 54 | { 55 | int reg = address >> 11; 56 | switch (reg) 57 | { 58 | case 0xA: 59 | irq.counter &= ~0xFF; 60 | irq.counter |= value; 61 | break; 62 | 63 | case 0xB: 64 | irq.counter = ((value & 0x7F) << 8) | (irq.counter & 0xFF); 65 | irq.enabled = (value & 0x80) ? true : false; 66 | break; 67 | 68 | case 0x10: 69 | case 0x11: 70 | case 0x12: 71 | case 0x13: 72 | case 0x14: 73 | case 0x15: 74 | case 0x16: 75 | case 0x17: 76 | mmc_bankvrom(1, (reg & 7) << 10, value); 77 | break; 78 | 79 | case 0x18: 80 | case 0x19: 81 | case 0x1A: 82 | case 0x1B: 83 | N_BANK1(reg & 3, value); 84 | break; 85 | 86 | case 0x1C: 87 | mmc_bankrom(8, 0x8000, value); 88 | break; 89 | 90 | case 0x1D: 91 | mmc_bankrom(8, 0xA000, value); 92 | break; 93 | 94 | case 0x1E: 95 | mmc_bankrom(8, 0xC000, value); 96 | break; 97 | 98 | default: 99 | break; 100 | } 101 | } 102 | 103 | static void map19_getstate(SnssMapperBlock *state) 104 | { 105 | state->extraData.mapper19.irqCounterLowByte = irq.counter & 0xFF; 106 | state->extraData.mapper19.irqCounterHighByte = irq.counter >> 8; 107 | state->extraData.mapper19.irqCounterEnabled = irq.enabled; 108 | } 109 | 110 | static void map19_setstate(SnssMapperBlock *state) 111 | { 112 | irq.counter = (state->extraData.mapper19.irqCounterHighByte << 8) 113 | | state->extraData.mapper19.irqCounterLowByte; 114 | irq.enabled = state->extraData.mapper19.irqCounterEnabled; 115 | } 116 | 117 | static map_memwrite map19_memwrite[] = 118 | { 119 | { 0x5000, 0x5FFF, map19_write }, 120 | { 0x8000, 0xFFFF, map19_write }, 121 | { -1, -1, NULL } 122 | }; 123 | 124 | mapintf_t map19_intf = 125 | { 126 | 19, /* mapper number */ 127 | "Namcot 106", /* mapper name */ 128 | map19_init, /* init routine */ 129 | NULL, /* vblank callback */ 130 | NULL, /* hblank callback */ 131 | map19_getstate, /* get state (snss) */ 132 | map19_setstate, /* set state (snss) */ 133 | NULL, /* memory read structure */ 134 | map19_memwrite, /* memory write structure */ 135 | NULL /* external sound device */ 136 | }; 137 | 138 | /* 139 | ** $Log: map019.c,v $ 140 | ** Revision 1.2 2001/04/27 14:37:11 neil 141 | ** wheeee 142 | ** 143 | ** Revision 1.1 2001/04/27 12:54:40 neil 144 | ** blah 145 | ** 146 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 147 | ** initial 148 | ** 149 | ** Revision 1.1 2000/10/24 12:19:33 matt 150 | ** changed directory structure 151 | ** 152 | ** Revision 1.6 2000/10/22 19:17:46 matt 153 | ** mapper cleanups galore 154 | ** 155 | ** Revision 1.5 2000/10/21 19:33:38 matt 156 | ** many more cleanups 157 | ** 158 | ** Revision 1.4 2000/10/10 13:58:17 matt 159 | ** stroustrup squeezing his way in the door 160 | ** 161 | ** Revision 1.3 2000/07/15 23:52:20 matt 162 | ** rounded out a bunch more mapper interfaces 163 | ** 164 | ** Revision 1.2 2000/07/06 02:48:43 matt 165 | ** clearly labelled structure members 166 | ** 167 | ** Revision 1.1 2000/07/06 01:01:56 matt 168 | ** initial revision 169 | ** 170 | */ 171 | -------------------------------------------------------------------------------- /lib/nofrendo/src/vid_drv.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 | ** vid_drv.h 21 | ** 22 | ** Video driver 23 | ** $Id: vid_drv.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _VID_DRV_H_ 27 | #define _VID_DRV_H_ 28 | 29 | #include 30 | 31 | typedef struct viddriver_s 32 | { 33 | /* name of driver */ 34 | const char *name; 35 | /* init function - return 0 on success, nonzero on failure */ 36 | int (*init)(int width, int height); 37 | /* clean up after driver (can be NULL) */ 38 | void (*shutdown)(void); 39 | /* set a video mode - return 0 on success, nonzero on failure */ 40 | int (*set_mode)(int width, int height); 41 | /* set up a palette */ 42 | void (*set_palette)(rgb_t *palette); 43 | /* custom bitmap clear (can be NULL) */ 44 | void (*clear)(uint8 color); 45 | /* lock surface for writing (required) */ 46 | bitmap_t *(*lock_write)(void); 47 | /* free a locked surface (can be NULL) */ 48 | void (*free_write)(int num_dirties, rect_t *dirty_rects); 49 | /* custom blitter - num_dirties == -1 if full blit required */ 50 | void (*custom_blit)(bitmap_t *primary, int num_dirties, 51 | rect_t *dirty_rects); 52 | /* immediately invalidate the buffer, i.e. full redraw */ 53 | bool invalidate; 54 | } viddriver_t; 55 | 56 | /* TODO: filth */ 57 | extern bitmap_t *vid_getbuffer(void); 58 | 59 | extern int vid_init(int width, int height, viddriver_t *osd_driver); 60 | extern void vid_shutdown(void); 61 | 62 | extern int vid_setmode(int width, int height); 63 | extern void vid_setpalette(rgb_t *pal); 64 | 65 | extern void vid_blit(bitmap_t *bitmap, int src_x, int src_y, int dest_x, 66 | int dest_y, int blit_width, int blit_height); 67 | extern void vid_flush(void); 68 | 69 | #endif /* _VID_DRV_H_ */ 70 | 71 | /* 72 | ** $Log: vid_drv.h,v $ 73 | ** Revision 1.2 2001/04/27 14:37:11 neil 74 | ** wheeee 75 | ** 76 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 77 | ** initial 78 | ** 79 | ** Revision 1.22 2000/11/05 22:53:13 matt 80 | ** only one video driver per system, please 81 | ** 82 | ** Revision 1.21 2000/11/05 16:37:18 matt 83 | ** rolled rgb.h into bitmap.h 84 | ** 85 | ** Revision 1.20 2000/11/05 06:23:41 matt 86 | ** thinlib spawns changes 87 | ** 88 | ** Revision 1.19 2000/10/10 13:58:14 matt 89 | ** stroustrup squeezing his way in the door 90 | ** 91 | ** Revision 1.18 2000/10/10 13:03:54 matt 92 | ** Mr. Clean makes a guest appearance 93 | ** 94 | ** Revision 1.17 2000/08/16 02:53:04 matt 95 | ** changed init() interface a wee bit 96 | ** 97 | ** Revision 1.16 2000/07/31 04:28:47 matt 98 | ** one million cleanups 99 | ** 100 | ** Revision 1.15 2000/07/28 07:25:49 neil 101 | ** Video driver has an invalidate flag, telling vid_drv not to calculate dirties for the next frame 102 | ** 103 | ** Revision 1.14 2000/07/27 23:49:52 matt 104 | ** no more getmode 105 | ** 106 | ** Revision 1.13 2000/07/27 04:30:37 matt 107 | ** change to get_mode api 108 | ** 109 | ** Revision 1.12 2000/07/27 04:08:04 matt 110 | ** char * -> const char * 111 | ** 112 | ** Revision 1.11 2000/07/27 04:05:58 matt 113 | ** changed place where name goes 114 | ** 115 | ** Revision 1.10 2000/07/27 01:16:22 matt 116 | ** api changes for new main and dirty rects 117 | ** 118 | ** Revision 1.9 2000/07/26 21:36:14 neil 119 | ** Big honkin' change -- see the mailing list 120 | ** 121 | ** Revision 1.8 2000/07/24 04:33:57 matt 122 | ** skeleton of dirty rectangle code in place 123 | ** 124 | ** Revision 1.7 2000/07/10 19:07:57 matt 125 | ** added custom clear() member call to video driver 126 | ** 127 | ** Revision 1.6 2000/07/10 03:04:15 matt 128 | ** removed scanlines, backbuffer from custom blit 129 | ** 130 | ** Revision 1.5 2000/07/10 01:03:20 neil 131 | ** New video scheme allows for custom blitters to be determined by the driver at runtime 132 | ** 133 | ** Revision 1.4 2000/07/09 03:34:47 matt 134 | ** temporary cleanup 135 | ** 136 | ** Revision 1.3 2000/07/07 20:17:35 matt 137 | ** better custom blitting support 138 | ** 139 | ** Revision 1.2 2000/07/07 18:11:38 neil 140 | ** Generalizing the video driver 141 | ** 142 | ** Revision 1.1 2000/07/06 16:48:47 matt 143 | ** initial revision 144 | ** 145 | */ 146 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map016.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 | ** map16.c 21 | ** 22 | ** mapper 16 interface 23 | ** $Id: map016.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | static struct 32 | { 33 | int counter; 34 | bool enabled; 35 | } irq; 36 | 37 | /* mapper 16: Bandai */ 38 | 39 | static void map16_init(void) 40 | { 41 | mmc_bankrom(16, 0x8000, 0); 42 | mmc_bankrom(16, 0xC000, MMC_LASTBANK); 43 | irq.counter = 0; 44 | irq.enabled = false; 45 | } 46 | 47 | static void map16_write(uint32 address, uint8 value) 48 | { 49 | int reg = address & 0xF; 50 | 51 | if (reg < 8) 52 | { 53 | mmc_bankvrom(1, reg << 10, value); 54 | } 55 | else 56 | { 57 | switch (address & 0x000F) 58 | { 59 | case 0x8: 60 | mmc_bankrom(16, 0x8000, value); 61 | break; 62 | 63 | case 0x9: 64 | switch (value & 3) 65 | { 66 | case 0: 67 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 68 | break; 69 | 70 | case 1: 71 | ppu_mirror(0, 1, 0, 1); /* vertical */ 72 | break; 73 | 74 | case 2: 75 | ppu_mirror(0, 0, 0, 0); 76 | break; 77 | 78 | case 3: 79 | ppu_mirror(1, 1, 1, 1); 80 | break; 81 | } 82 | break; 83 | 84 | case 0xA: 85 | irq.enabled = (value & 1) ? true : false; 86 | break; 87 | 88 | case 0xB: 89 | irq.counter = (irq.counter & 0xFF00) | value; 90 | break; 91 | 92 | case 0xC: 93 | irq.counter = (value << 8) | (irq.counter & 0xFF); 94 | break; 95 | 96 | case 0xD: 97 | /* eeprom I/O port? */ 98 | break; 99 | } 100 | } 101 | } 102 | 103 | static void map16_hblank(int vblank) 104 | { 105 | UNUSED(vblank); 106 | 107 | if (irq.enabled) 108 | { 109 | if (irq.counter) 110 | { 111 | if (0 == --irq.counter) 112 | nes_irq(); 113 | } 114 | } 115 | } 116 | 117 | static void map16_getstate(SnssMapperBlock *state) 118 | { 119 | state->extraData.mapper16.irqCounterLowByte = irq.counter & 0xFF; 120 | state->extraData.mapper16.irqCounterHighByte = irq.counter >> 8; 121 | state->extraData.mapper16.irqCounterEnabled = irq.enabled; 122 | } 123 | 124 | static void map16_setstate(SnssMapperBlock *state) 125 | { 126 | irq.counter = (state->extraData.mapper16.irqCounterHighByte << 8) 127 | | state->extraData.mapper16.irqCounterLowByte; 128 | irq.enabled = state->extraData.mapper16.irqCounterEnabled; 129 | } 130 | 131 | static map_memwrite map16_memwrite[] = 132 | { 133 | { 0x6000, 0x600D, map16_write }, 134 | { 0x7FF0, 0x7FFD, map16_write }, 135 | { 0x8000, 0x800D, map16_write }, 136 | { -1, -1, NULL } 137 | }; 138 | 139 | mapintf_t map16_intf = 140 | { 141 | 16, /* mapper number */ 142 | "Bandai", /* mapper name */ 143 | map16_init, /* init routine */ 144 | NULL, /* vblank callback */ 145 | map16_hblank, /* hblank callback */ 146 | map16_getstate, /* get state (snss) */ 147 | map16_setstate, /* set state (snss) */ 148 | NULL, /* memory read structure */ 149 | map16_memwrite, /* memory write structure */ 150 | NULL /* external sound device */ 151 | }; 152 | 153 | /* 154 | ** $Log: map016.c,v $ 155 | ** Revision 1.2 2001/04/27 14:37:11 neil 156 | ** wheeee 157 | ** 158 | ** Revision 1.1 2001/04/27 12:54:40 neil 159 | ** blah 160 | ** 161 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 162 | ** initial 163 | ** 164 | ** Revision 1.1 2000/10/24 12:19:33 matt 165 | ** changed directory structure 166 | ** 167 | ** Revision 1.8 2000/10/22 19:17:46 matt 168 | ** mapper cleanups galore 169 | ** 170 | ** Revision 1.7 2000/10/22 15:03:13 matt 171 | ** simplified mirroring 172 | ** 173 | ** Revision 1.6 2000/10/21 19:33:38 matt 174 | ** many more cleanups 175 | ** 176 | ** Revision 1.5 2000/10/10 13:58:16 matt 177 | ** stroustrup squeezing his way in the door 178 | ** 179 | ** Revision 1.4 2000/08/16 02:50:11 matt 180 | ** random mapper cleanups 181 | ** 182 | ** Revision 1.3 2000/07/15 23:52:20 matt 183 | ** rounded out a bunch more mapper interfaces 184 | ** 185 | ** Revision 1.2 2000/07/11 05:03:49 matt 186 | ** value masking isn't necessary for the banking routines 187 | ** 188 | ** Revision 1.1 2000/07/11 03:14:18 melanson 189 | ** Initial commit for mappers 16, 34, and 231 190 | ** 191 | ** 192 | */ 193 | -------------------------------------------------------------------------------- /lib/nofrendo/src/cpu/nes6502.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 | ** nes6502.h 21 | ** 22 | ** NES custom 6502 CPU definitions / prototypes 23 | ** $Id: nes6502.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | /* NOTE: 16-bit addresses avoided like the plague: use 32-bit values 27 | ** wherever humanly possible 28 | */ 29 | #ifndef _NES6502_H_ 30 | #define _NES6502_H_ 31 | 32 | #include 33 | 34 | /* Define this to enable decimal mode in ADC / SBC (not needed in NES) */ 35 | /*#define NES6502_DECIMAL*/ 36 | 37 | #define NES6502_NUMBANKS 16 38 | #define NES6502_BANKSHIFT 12 39 | #define NES6502_BANKSIZE (0x10000 / NES6502_NUMBANKS) 40 | #define NES6502_BANKMASK (NES6502_BANKSIZE - 1) 41 | 42 | /* P (flag) register bitmasks */ 43 | #define N_FLAG 0x80 44 | #define V_FLAG 0x40 45 | #define R_FLAG 0x20 /* Reserved, always 1 */ 46 | #define B_FLAG 0x10 47 | #define D_FLAG 0x08 48 | #define I_FLAG 0x04 49 | #define Z_FLAG 0x02 50 | #define C_FLAG 0x01 51 | 52 | /* Vector addresses */ 53 | #define NMI_VECTOR 0xFFFA 54 | #define RESET_VECTOR 0xFFFC 55 | #define IRQ_VECTOR 0xFFFE 56 | 57 | /* cycle counts for interrupts */ 58 | #define INT_CYCLES 7 59 | #define RESET_CYCLES 6 60 | 61 | #define NMI_MASK 0x01 62 | #define IRQ_MASK 0x02 63 | 64 | /* Stack is located on 6502 page 1 */ 65 | #define STACK_OFFSET 0x0100 66 | 67 | typedef struct 68 | { 69 | uint32 min_range, max_range; 70 | uint8 (*read_func)(uint32 address); 71 | } nes6502_memread; 72 | 73 | typedef struct 74 | { 75 | uint32 min_range, max_range; 76 | int (*write_func)(uint32 address, uint8 value); 77 | } nes6502_memwrite; 78 | 79 | typedef struct 80 | { 81 | uint8 *mem_page[NES6502_NUMBANKS]; /* memory page pointers */ 82 | 83 | nes6502_memread *read_handler; 84 | nes6502_memwrite *write_handler; 85 | 86 | uint32 pc_reg; 87 | uint8 a_reg, p_reg; 88 | uint8 x_reg, y_reg; 89 | uint8 s_reg; 90 | 91 | uint8 jammed; /* is processor jammed? */ 92 | 93 | uint8 int_pending, int_latency; 94 | 95 | int32 total_cycles, burn_cycles; 96 | } nes6502_context; 97 | 98 | #ifdef __cplusplus 99 | extern "C" { 100 | #endif /* __cplusplus */ 101 | 102 | /* Functions which govern the 6502's execution */ 103 | extern void nes6502_reset(void); 104 | extern int nes6502_execute(int total_cycles); 105 | extern void nes6502_nmi(void); 106 | extern void nes6502_irq(void); 107 | extern uint8 nes6502_getbyte(uint32 address); 108 | extern uint32 nes6502_getcycles(bool reset_flag); 109 | extern void nes6502_burn(int cycles); 110 | extern void nes6502_release(void); 111 | 112 | /* Context get/set */ 113 | extern void nes6502_setcontext(nes6502_context *cpu); 114 | extern void nes6502_getcontext(nes6502_context *cpu); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif /* __cplusplus */ 119 | 120 | #endif /* _NES6502_H_ */ 121 | 122 | /* 123 | ** $Log: nes6502.h,v $ 124 | ** Revision 1.2 2001/04/27 14:37:11 neil 125 | ** wheeee 126 | ** 127 | ** Revision 1.1 2001/04/27 12:54:39 neil 128 | ** blah 129 | ** 130 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 131 | ** initial 132 | ** 133 | ** Revision 1.17 2000/11/13 00:57:39 matt 134 | ** trying to add 1-instruction interrupt latency... and failing. 135 | ** 136 | ** Revision 1.16 2000/10/27 12:53:36 matt 137 | ** banks are always 4kB now 138 | ** 139 | ** Revision 1.15 2000/10/10 13:58:14 matt 140 | ** stroustrup squeezing his way in the door 141 | ** 142 | ** Revision 1.14 2000/09/15 03:42:32 matt 143 | ** nes6502_release to release current timeslice 144 | ** 145 | ** Revision 1.13 2000/09/11 03:55:32 matt 146 | ** cosmetics 147 | ** 148 | ** Revision 1.12 2000/09/08 11:54:48 matt 149 | ** optimize 150 | ** 151 | ** Revision 1.11 2000/09/07 21:58:18 matt 152 | ** api change for nes6502_burn, optimized core 153 | ** 154 | ** Revision 1.10 2000/09/07 01:34:55 matt 155 | ** nes6502_init deprecated, moved flag regs to separate vars 156 | ** 157 | ** Revision 1.9 2000/08/28 12:53:44 matt 158 | ** fixes for disassembler 159 | ** 160 | ** Revision 1.8 2000/08/28 01:46:15 matt 161 | ** moved some of them defines around, cleaned up jamming code 162 | ** 163 | ** Revision 1.7 2000/08/16 04:56:37 matt 164 | ** accurate CPU jamming, added dead page emulation 165 | ** 166 | ** Revision 1.6 2000/07/30 04:32:00 matt 167 | ** now emulates the NES frame IRQ 168 | ** 169 | ** Revision 1.5 2000/07/17 01:52:28 matt 170 | ** made sure last line of all source files is a newline 171 | ** 172 | ** Revision 1.4 2000/06/09 15:12:25 matt 173 | ** initial revision 174 | ** 175 | */ 176 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map073.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 | ** map073.c 21 | ** 22 | ** Mapper #73 (Konami VRC3) 23 | ** Implementation by Firebug 24 | ** $Id: map073.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 | static struct 35 | { 36 | bool enabled; 37 | uint32 counter; 38 | } irq; 39 | 40 | /**************************/ 41 | /* Mapper #73: Salamander */ 42 | /**************************/ 43 | static void map73_init (void) 44 | { 45 | /* Turn off IRQs */ 46 | irq.enabled = false; 47 | irq.counter = 0x0000; 48 | 49 | /* Done */ 50 | return; 51 | } 52 | 53 | /****************************************/ 54 | /* Mapper #73 callback for IRQ handling */ 55 | /****************************************/ 56 | static void map73_hblank (int vblank) 57 | { 58 | /* Counter is M2 based so it doesn't matter whether */ 59 | /* the PPU is in its VBlank period or not */ 60 | UNUSED (vblank); 61 | 62 | /* Increment the counter if it is enabled and check for strike */ 63 | if (irq.enabled) 64 | { 65 | /* Is there a constant for cycles per scanline? */ 66 | /* If so, someone ought to substitute it here */ 67 | irq.counter = irq.counter + 114; 68 | 69 | /* Counter triggered on overflow into Q16 */ 70 | if (irq.counter & 0x10000) 71 | { 72 | /* Clip to sixteen-bit word */ 73 | irq.counter &= 0xFFFF; 74 | 75 | /* Trigger the IRQ */ 76 | nes_irq (); 77 | 78 | /* Shut off IRQ counter */ 79 | irq.enabled = false; 80 | } 81 | } 82 | } 83 | 84 | /******************************************/ 85 | /* Mapper #73 write handler ($8000-$FFFF) */ 86 | /******************************************/ 87 | static void map73_write (uint32 address, uint8 value) 88 | { 89 | switch (address & 0xF000) 90 | { 91 | case 0x8000: irq.counter &= 0xFFF0; 92 | irq.counter |= (uint32) (value); 93 | break; 94 | case 0x9000: irq.counter &= 0xFF0F; 95 | irq.counter |= (uint32) (value << 4); 96 | break; 97 | case 0xA000: irq.counter &= 0xF0FF; 98 | irq.counter |= (uint32) (value << 8); 99 | break; 100 | case 0xB000: irq.counter &= 0x0FFF; 101 | irq.counter |= (uint32) (value << 12); 102 | break; 103 | case 0xC000: if (value & 0x02) irq.enabled = true; 104 | else irq.enabled = false; 105 | break; 106 | case 0xF000: mmc_bankrom (16, 0x8000, value); 107 | default: break; 108 | } 109 | 110 | /* Done */ 111 | return; 112 | } 113 | 114 | /****************************************************/ 115 | /* Shove extra mapper information into a SNSS block */ 116 | /****************************************************/ 117 | static void map73_setstate (SnssMapperBlock *state) 118 | { 119 | /* TODO: Store SNSS information */ 120 | UNUSED (state); 121 | 122 | /* Done */ 123 | return; 124 | } 125 | 126 | /*****************************************************/ 127 | /* Pull extra mapper information out of a SNSS block */ 128 | /*****************************************************/ 129 | static void map73_getstate (SnssMapperBlock *state) 130 | { 131 | /* TODO: Retrieve SNSS information */ 132 | UNUSED (state); 133 | 134 | /* Done */ 135 | return; 136 | } 137 | 138 | static map_memwrite map73_memwrite [] = 139 | { 140 | { 0x8000, 0xFFFF, map73_write }, 141 | { -1, -1, NULL } 142 | }; 143 | 144 | mapintf_t map73_intf = 145 | { 146 | 73, /* Mapper number */ 147 | "Konami VRC3", /* Mapper name */ 148 | map73_init, /* Initialization routine */ 149 | NULL, /* VBlank callback */ 150 | map73_hblank, /* HBlank callback */ 151 | map73_getstate, /* Get state (SNSS) */ 152 | map73_setstate, /* Set state (SNSS) */ 153 | NULL, /* Memory read structure */ 154 | map73_memwrite, /* Memory write structure */ 155 | NULL /* External sound device */ 156 | }; 157 | 158 | /* 159 | ** $Log: map073.c,v $ 160 | ** Revision 1.2 2001/04/27 14:37:11 neil 161 | ** wheeee 162 | ** 163 | ** Revision 1.1 2001/04/27 12:54:40 neil 164 | ** blah 165 | ** 166 | ** Revision 1.1 2001/04/27 10:57:41 neil 167 | ** wheee 168 | ** 169 | ** Revision 1.1 2000/12/30 06:35:05 firebug 170 | ** Initial revision 171 | ** 172 | ** 173 | */ 174 | -------------------------------------------------------------------------------- /lib/nofrendo/src/mappers/map041.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 | ** map041.c 21 | ** 22 | ** Mapper #41 (Caltron 6 in 1) 23 | ** Implementation by Firebug 24 | ** Mapper information courtesy of Kevin Horton 25 | ** $Id: map041.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 | static uint8 register_low; 36 | static uint8 register_high; 37 | 38 | /*****************************************************/ 39 | /* Set 8K CHR bank from the combined register values */ 40 | /*****************************************************/ 41 | static void map41_set_chr (void) 42 | { 43 | /* Set the CHR bank from the appropriate register bits */ 44 | mmc_bankvrom (8, 0x0000, ((register_low >> 1) & 0x0C) | (register_high)); 45 | 46 | /* Done */ 47 | return; 48 | } 49 | 50 | /******************************/ 51 | /* Mapper #41: Caltron 6 in 1 */ 52 | /******************************/ 53 | static void map41_init (void) 54 | { 55 | /* Both registers set to zero at power on */ 56 | /* TODO: Registers should also be cleared on a soft reset */ 57 | register_low = 0x00; 58 | register_high = 0x00; 59 | mmc_bankrom (32, 0x8000, 0x00); 60 | map41_set_chr (); 61 | 62 | /* Done */ 63 | return; 64 | } 65 | 66 | /******************************************/ 67 | /* Mapper #41 write handler ($6000-$67FF) */ 68 | /******************************************/ 69 | static void map41_low_write (uint32 address, uint8 value) 70 | { 71 | /* Within this range the value written is irrelevant */ 72 | UNUSED (value); 73 | 74 | /* $6000-$67FF: A5 = mirroring (1=horizontal, 0=vertical) */ 75 | /* A4-A3 = high two bits of 8K CHR bank */ 76 | /* A2 = register 1 enable (0=disabled, 1=enabled) */ 77 | /* A2-A0 = 32K PRG bank */ 78 | register_low = (uint8) (address & 0x3F); 79 | mmc_bankrom (32, 0x8000, register_low & 0x07); 80 | map41_set_chr (); 81 | if (register_low & 0x20) ppu_mirror(0, 0, 1, 1); /* horizontal */ 82 | else ppu_mirror(0, 1, 0, 1); /* vertical */ 83 | 84 | /* Done */ 85 | return; 86 | } 87 | 88 | /******************************************/ 89 | /* Mapper #41 write handler ($8000-$FFFF) */ 90 | /******************************************/ 91 | static void map41_high_write (uint32 address, uint8 value) 92 | { 93 | /* Address doesn't matter within this range */ 94 | UNUSED (address); 95 | 96 | /* $8000-$FFFF: D1-D0 = low two bits of 8K CHR bank */ 97 | if (register_low & 0x04) 98 | { 99 | register_high = value & 0x03; 100 | map41_set_chr (); 101 | } 102 | 103 | /* Done */ 104 | return; 105 | } 106 | 107 | /****************************************************/ 108 | /* Shove extra mapper information into a SNSS block */ 109 | /****************************************************/ 110 | static void map41_setstate (SnssMapperBlock *state) 111 | { 112 | /* TODO: Store SNSS information */ 113 | UNUSED (state); 114 | 115 | /* Done */ 116 | return; 117 | } 118 | 119 | /*****************************************************/ 120 | /* Pull extra mapper information out of a SNSS block */ 121 | /*****************************************************/ 122 | static void map41_getstate (SnssMapperBlock *state) 123 | { 124 | /* TODO: Retrieve SNSS information */ 125 | UNUSED (state); 126 | 127 | /* Done */ 128 | return; 129 | } 130 | 131 | static map_memwrite map41_memwrite [] = 132 | { 133 | { 0x6000, 0x67FF, map41_low_write }, 134 | { 0x8000, 0xFFFF, map41_high_write }, 135 | { -1, -1, NULL } 136 | }; 137 | 138 | mapintf_t map41_intf = 139 | { 140 | 41, /* Mapper number */ 141 | "Caltron 6 in 1", /* Mapper name */ 142 | map41_init, /* Initialization routine */ 143 | NULL, /* VBlank callback */ 144 | NULL, /* HBlank callback */ 145 | map41_getstate, /* Get state (SNSS) */ 146 | map41_setstate, /* Set state (SNSS) */ 147 | NULL, /* Memory read structure */ 148 | map41_memwrite, /* Memory write structure */ 149 | NULL /* External sound device */ 150 | }; 151 | 152 | /* 153 | ** $Log: map041.c,v $ 154 | ** Revision 1.2 2001/04/27 14:37:11 neil 155 | ** wheeee 156 | ** 157 | ** Revision 1.1 2001/04/27 12:54:40 neil 158 | ** blah 159 | ** 160 | ** Revision 1.1 2001/04/27 10:57:41 neil 161 | ** wheee 162 | ** 163 | ** Revision 1.1 2000/12/30 00:33:15 firebug 164 | ** initial revision 165 | ** 166 | ** 167 | */ 168 | -------------------------------------------------------------------------------- /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:heltec_wifi_kit_32] 12 | platform = espressif32 13 | board = heltec_wifi_kit_32 14 | framework = espidf 15 | board_build.partitions = partitions.csv 16 | monitor_speed=115200 17 | 18 | build_flags = 19 | # Heltec uses a different clock frequency, the default 40mhz results in the wrong baud rate and garbarge serial data 20 | -DCONFIG_ESP32_XTAL_FREQ=26 21 | # Turn on debugging 22 | -DNOFRENDO_DEBUG 23 | # -DCONFIG_FREERTOS_HZ=300 (it's a multiple of 50hz and 60hz) -- this is set in sdkconfig.h 24 | # PAL timing (feels too slow) 25 | # -DPAL 26 | # NTSC timing defaults if PAL not defined 27 | # Sound Settings 28 | -DCONFIG_SOUND_ENABLED 29 | # Note: Do not assign anything else to pins 25 or 26, those are used by I2S 30 | # LCD Settings 31 | -DCONFIG_HW_LCD_CS_GPIO=5 32 | -DCONFIG_HW_LCD_RESET_GPIO=0 33 | -DCONFIG_HW_LCD_DC_GPIO=2 34 | -DCONFIG_HW_LCD_MOSI_GPIO=23 35 | -DCONFIG_HW_LCD_CLK_GPIO=18 36 | -DCONFIG_HW_LCD_BL_GPIO=-1 37 | -DCONFIG_HW_LCD_MISO_GPIO=19 38 | # Requires using VSPI bus, disable locks to speed up transfers 39 | -DCONFIG_HW_LCD_CLOCK_SPEED=80 40 | -DDISABLE_HAL_LOCKS=1 41 | # Pin mappings for PSX input 42 | -DCONFIG_HW_CONTROLLER_PSX 43 | # MISO 44 | -DCONFIG_HW_PSX_DAT=21 45 | # MOSI 46 | -DCONFIG_HW_PSX_CMD=4 47 | # CS 48 | -DCONFIG_HW_PSX_ATT=27 49 | # CLK 50 | -DCONFIG_HW_PSX_CLK=22 51 | # Pin mappings for SD card 52 | -DCONFIG_SD_CARD 53 | -DCONFIG_SD_CS=15 54 | -DCONFIG_SD_MOSI=13 55 | -DCONFIG_SD_SCK=14 56 | -DCONFIG_SD_MISO=12 57 | #Pin mappings for GPIO (raw button input) 58 | # -DCONFIG_HW_CONTROLLER_GPIO 59 | -DCONFIG_HW_GPIO_START=1 60 | -DCONFIG_HW_GPIO_SELECT=1 61 | -DCONFIG_HW_GPIO_UP=1 62 | -DCONFIG_HW_GPIO_DOWN=1 63 | -DCONFIG_HW_GPIO_LEFT=1 64 | -DCONFIG_HW_GPIO_RIGHT=1 65 | -DCONFIG_HW_GPIO_B=1 66 | -DCONFIG_HW_GPIO_A=1 67 | #Also referred to as Button 2 68 | -DCONFIG_HW_GPIO_MENU=1 69 | #Also referred to as Button 1 70 | -DCONFIG_HW_GPIO_POWER=1 71 | -DCONFIG_HW_GPIO_TURBO_A=1 72 | -DCONFIG_HW_GPIO_TURBO_B=1 73 | #Include boot logo 74 | -DCOMPONENT_EMBED_TXTFILES=lib/menu/data/image.jpg 75 | # Bypass compile errors in the Nofrendo code 76 | -Wno-error=char-subscripts 77 | -Wno-error=attributes 78 | -Wno-error=maybe-uninitialized 79 | # New platform version causes new build errors to trigger 80 | # -Wno-error=misleading-indentation 81 | # -Wno-error=unused-const-variable 82 | # -Wno-error=format-truncation 83 | -g 84 | 85 | [env:ke32-wrover-c20] 86 | # Same settings as Heltec board, but for one based on wrover-kit, 87 | # only difference is XTAL frequency and flash size (but we use the same partition map for both right now) 88 | platform = espressif32 89 | board = ke32-wrover-c20 90 | framework = espidf 91 | board_build.partitions = partitions.csv 92 | monitor_speed=115200 93 | 94 | build_flags = 95 | # Turn on debugging 96 | -DNOFRENDO_DEBUG 97 | # -DCONFIG_FREERTOS_HZ=300 (it's a multiple of 50hz and 60hz) -- this is set in sdkconfig.h 98 | # PAL timing (feels too slow) 99 | # -DPAL 100 | # NTSC timing defaults if PAL not defined 101 | # Sound Settings 102 | -DCONFIG_SOUND_ENABLED 103 | # Note: Do not assign anything else to pins 25 or 26, those are used by I2S 104 | # LCD Settings 105 | -DCONFIG_HW_LCD_CS_GPIO=5 106 | -DCONFIG_HW_LCD_RESET_GPIO=0 107 | -DCONFIG_HW_LCD_DC_GPIO=2 108 | -DCONFIG_HW_LCD_MOSI_GPIO=23 109 | -DCONFIG_HW_LCD_CLK_GPIO=18 110 | -DCONFIG_HW_LCD_BL_GPIO=-1 111 | -DCONFIG_HW_LCD_MISO_GPIO=19 112 | # Requires using VSPI bus, disable locks to speed up transfers 113 | -DCONFIG_HW_LCD_CLOCK_SPEED=80 114 | -DDISABLE_HAL_LOCKS=1 115 | # Pin mappings for PSX input 116 | -DCONFIG_HW_CONTROLLER_PSX 117 | # MISO 118 | -DCONFIG_HW_PSX_DAT=21 119 | # MOSI 120 | -DCONFIG_HW_PSX_CMD=4 121 | # CS 122 | -DCONFIG_HW_PSX_ATT=27 123 | # CLK 124 | -DCONFIG_HW_PSX_CLK=22 125 | # Pin mappings for SD card 126 | -DCONFIG_SD_CARD 127 | -DCONFIG_SD_CS=15 128 | -DCONFIG_SD_MOSI=13 129 | -DCONFIG_SD_SCK=14 130 | -DCONFIG_SD_MISO=12 131 | #Pin mappings for GPIO (raw button input) 132 | # -DCONFIG_HW_CONTROLLER_GPIO 133 | -DCONFIG_HW_GPIO_START=1 134 | -DCONFIG_HW_GPIO_SELECT=1 135 | -DCONFIG_HW_GPIO_UP=1 136 | -DCONFIG_HW_GPIO_DOWN=1 137 | -DCONFIG_HW_GPIO_LEFT=1 138 | -DCONFIG_HW_GPIO_RIGHT=1 139 | -DCONFIG_HW_GPIO_B=1 140 | -DCONFIG_HW_GPIO_A=1 141 | #Also referred to as Button 2 142 | -DCONFIG_HW_GPIO_MENU=1 143 | #Also referred to as Button 1 144 | -DCONFIG_HW_GPIO_POWER=1 145 | -DCONFIG_HW_GPIO_TURBO_A=1 146 | -DCONFIG_HW_GPIO_TURBO_B=1 147 | #Include boot logo 148 | -DCOMPONENT_EMBED_TXTFILES=lib/menu/data/image.jpg 149 | # Bypass compile errors in the Nofrendo code 150 | -Wno-error=char-subscripts 151 | -Wno-error=attributes 152 | -Wno-error=maybe-uninitialized 153 | # New platform version causes new build errors to trigger 154 | # -Wno-error=misleading-indentation 155 | # -Wno-error=unused-const-variable 156 | # -Wno-error=format-truncation 157 | -g 158 | -------------------------------------------------------------------------------- /lib/menu/src/decode_image.c: -------------------------------------------------------------------------------- 1 | /* SPI Master example: jpeg decoder. 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | 11 | /* 12 | The image used for the effect on the LCD in the SPI master example is stored in flash 13 | as a jpeg file. This file contains the decode_image routine, which uses the tiny JPEG 14 | decoder library in ROM to decode this JPEG into a format that can be sent to the display. 15 | 16 | Keep in mind that the decoder library cannot handle progressive files (will give 17 | ``Image decoder: jd_prepare failed (8)`` as an error) so make sure to save in the correct 18 | format if you want to use a different image file. 19 | */ 20 | 21 | 22 | #include "decode_image.h" 23 | #include "rom/tjpgd.h" 24 | #include "esp_log.h" 25 | #include 26 | 27 | //Reference the binary-included jpeg file -- defined by the build 28 | extern const uint8_t image_jpg_start[] asm("_binary_lib_menu_data_image_jpg_start"); 29 | extern const uint8_t image_jpg_end[] asm("_binary_lib_menu_data_image_jpg_end"); 30 | //Define the height and width of the jpeg file. Make sure this matches the actual jpeg 31 | //dimensions. 32 | #define IMAGE_W 113//336 33 | #define IMAGE_H 256 34 | 35 | 36 | const char *TAG="ImageDec"; 37 | 38 | 39 | //Data that is passed from the decoder function to the infunc/outfunc functions. 40 | typedef struct { 41 | const unsigned char *inData; //Pointer to jpeg data 42 | int inPos; //Current position in jpeg data 43 | uint16_t **outData; //Array of IMAGE_H pointers to arrays of IMAGE_W 16-bit pixel values 44 | int outW; //Width of the resulting file 45 | int outH; //Height of the resulting file 46 | } JpegDev; 47 | 48 | 49 | //Input function for jpeg decoder. Just returns bytes from the inData field of the JpegDev structure. 50 | static UINT infunc(JDEC *decoder, BYTE *buf, UINT len) 51 | { 52 | //Read bytes from input file 53 | JpegDev *jd=(JpegDev*)decoder->device; 54 | if (buf!=NULL) memcpy(buf, jd->inData+jd->inPos, len); 55 | jd->inPos+=len; 56 | return len; 57 | } 58 | 59 | //Output function. Re-encodes the RGB888 data from the decoder as big-endian RGB565 and 60 | //stores it in the outData array of the JpegDev structure. 61 | static UINT outfunc(JDEC *decoder, void *bitmap, JRECT *rect) 62 | { 63 | JpegDev *jd=(JpegDev*)decoder->device; 64 | uint8_t *in=(uint8_t*)bitmap; 65 | for (int y=rect->top; y<=rect->bottom; y++) { 66 | for (int x=rect->left; x<=rect->right; x++) { 67 | //We need to convert the 3 bytes in `in` to a rgb565 value. 68 | uint16_t v=0; 69 | v|=((in[0]>>3)<<11); 70 | v|=((in[1]>>2)<<5); 71 | v|=((in[2]>>3)<<0); 72 | //The LCD wants the 16-bit value in big-endian, so swap bytes 73 | v=(v>>8)|(v<<8); 74 | jd->outData[y][x]=v; 75 | in+=3; 76 | } 77 | } 78 | return 1; 79 | } 80 | 81 | //Size of the work space for the jpeg decoder. 82 | #define WORKSZ 3100 83 | 84 | //Decode the embedded image into pixel lines that can be used with the rest of the logic. 85 | esp_err_t decode_image(uint16_t ***pixels) 86 | { 87 | char *work=NULL; 88 | int r; 89 | JDEC decoder; 90 | JpegDev jd; 91 | *pixels=NULL; 92 | esp_err_t ret=ESP_OK; 93 | 94 | 95 | //Alocate pixel memory. Each line is an array of IMAGE_W 16-bit pixels; the `*pixels` array itself contains pointers to these lines. 96 | *pixels=calloc(IMAGE_H, sizeof(uint16_t*)); 97 | if (*pixels==NULL) { 98 | ESP_LOGE(TAG, "Error allocating memory for lines"); 99 | ret=ESP_ERR_NO_MEM; 100 | goto err; 101 | } 102 | for (int i=0; i