├── .gitignore ├── firmware ├── firmware.bin ├── BladeBuster.nes └── flash.sh ├── components ├── nofrendo-esp32 │ ├── psxcontroller.h │ ├── i2c_keyboard.h │ ├── component.mk │ ├── osd.c │ ├── spi_lcd.h │ ├── i2c_keyboard.c │ └── Kconfig.projbuild └── nofrendo │ ├── AUTHORS │ ├── component.mk │ ├── nes │ ├── mmclist.h │ ├── nesstate.h │ ├── nes_pal.h │ ├── nes_rom.h │ ├── nesinput.h │ ├── mmclist.c │ └── nes_mmc.h │ ├── intro.h │ ├── cpu │ ├── dis6502.h │ └── nes6502.h │ ├── sndhrdw │ ├── fds_snd.h │ ├── mmc5_snd.h │ ├── vrcvisnd.h │ └── fds_snd.c │ ├── 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 │ ├── map009.c │ └── map042.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 │ └── osd.h ├── flashrom.sh ├── Makefile ├── partitions.csv ├── main ├── component.mk └── main.c └── README.rst /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | build/ 3 | -------------------------------------------------------------------------------- /firmware/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/M5Stack-nesemu/HEAD/firmware/firmware.bin -------------------------------------------------------------------------------- /firmware/BladeBuster.nes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/M5Stack-nesemu/HEAD/firmware/BladeBuster.nes -------------------------------------------------------------------------------- /components/nofrendo-esp32/psxcontroller.h: -------------------------------------------------------------------------------- 1 | #ifndef PSXCONTROLLER_H 2 | #define PSXCONTROLLER_H 3 | 4 | int psxReadInput(); 5 | void psxcontrollerInit(); 6 | 7 | #endif -------------------------------------------------------------------------------- /flashrom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # . ${IDF_PATH}/add_path.sh 3 | ~/Documents/Arduino/hardware/espressif/esp32/tools/esptool --chip esp32 --port "/dev/cu.SLAB_USBtoUART" --baud $((115200)) write_flash -fs 4MB 0x100000 "$1" 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := nesemu 7 | 8 | include $(IDF_PATH)/make/project.mk 9 | 10 | -------------------------------------------------------------------------------- /firmware/flash.sh: -------------------------------------------------------------------------------- 1 | esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 firmware.bin 0x100000 BladeBuster.nes -------------------------------------------------------------------------------- /components/nofrendo-esp32/i2c_keyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef _I2C_KEYBOARD_H_ 2 | #define _I2C_KEYBOARD_H_ 3 | 4 | #include 5 | #include "driver/i2c.h" 6 | 7 | void i2c_keyboard_master_init(); 8 | uint8_t i2c_keyboard_read(); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size 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, 0x0E0000 6 | nesgame, 0x40, 0x01, 0x100000, 0x300000 7 | -------------------------------------------------------------------------------- /main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main 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 | -------------------------------------------------------------------------------- /components/nofrendo-esp32/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_DEPENDS := nofrendo 11 | COMPONENT_ADD_INCLUDEDIRS := . 12 | 13 | -------------------------------------------------------------------------------- /components/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 | -------------------------------------------------------------------------------- /components/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 | -------------------------------------------------------------------------------- /main/main.c: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "esp_wifi.h" 3 | #include "esp_system.h" 4 | #include "esp_event.h" 5 | #include "esp_event_loop.h" 6 | #include "nvs_flash.h" 7 | #include "driver/gpio.h" 8 | #include "nofrendo.h" 9 | #include "esp_partition.h" 10 | 11 | 12 | 13 | char *osd_getromdata() { 14 | char* romdata; 15 | const esp_partition_t* part; 16 | spi_flash_mmap_handle_t hrom; 17 | esp_err_t err; 18 | nvs_flash_init(); 19 | part=esp_partition_find_first(0x40, 1, NULL); 20 | if (part==0) printf("Couldn't find rom part!\n"); 21 | err=esp_partition_mmap(part, 0, 3*1024*1024, SPI_FLASH_MMAP_DATA, (const void**)&romdata, &hrom); 22 | if (err!=ESP_OK) printf("Couldn't map rom part!\n"); 23 | printf("Initialized. ROM@%p\n", romdata); 24 | return (char*)romdata; 25 | } 26 | 27 | 28 | esp_err_t event_handler(void *ctx, system_event_t *event) 29 | { 30 | return ESP_OK; 31 | } 32 | 33 | int app_main(void) 34 | { 35 | printf("NoFrendo start!\n"); 36 | nofrendo_main(0, NULL); 37 | printf("NoFrendo died? WtF?\n"); 38 | asm("break.n 1"); 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /components/nofrendo-esp32/osd.c: -------------------------------------------------------------------------------- 1 | /* vim: set tabstop=3 expandtab: 2 | ** 3 | ** This file is in the public domain. 4 | ** 5 | ** osd.c 6 | ** 7 | ** $Id: osd.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 8 | ** 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | char configfilename[]="na"; 32 | 33 | /* This is os-specific part of main() */ 34 | int osd_main(int argc, char *argv[]) 35 | { 36 | config.filename = configfilename; 37 | 38 | return main_loop("rom", system_autodetect); 39 | } 40 | 41 | /* File system interface */ 42 | void osd_fullname(char *fullname, const char *shortname) 43 | { 44 | strncpy(fullname, shortname, PATH_MAX); 45 | } 46 | 47 | /* This gives filenames for storage of saves */ 48 | char *osd_newextension(char *string, char *ext) 49 | { 50 | return string; 51 | } 52 | 53 | /* This gives filenames for storage of PCX snapshots */ 54 | int osd_makesnapname(char *filename, int len) 55 | { 56 | return -1; 57 | } 58 | -------------------------------------------------------------------------------- /components/nofrendo-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 | void ili9341_init(); 31 | 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // __SPI_H__ 38 | -------------------------------------------------------------------------------- /components/nofrendo/nes/mmclist.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** mmclist.h 21 | ** 22 | ** list of all mapper interfaces 23 | ** $Id: mmclist.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _MMCLIST_H_ 27 | #define _MMCLIST_H_ 28 | 29 | #include 30 | 31 | extern mapintf_t *mappers[]; 32 | 33 | #endif /* !_MMCLIST_H_ */ 34 | 35 | /* 36 | ** $Log: mmclist.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 41 | ** initial 42 | ** 43 | ** Revision 1.1 2000/10/24 12:20:28 matt 44 | ** changed directory structure 45 | ** 46 | ** Revision 1.1 2000/07/31 04:27:40 matt 47 | ** initial revision 48 | ** 49 | */ 50 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ESP32-NESEMU, a Nintendo Entertainment System emulator for the ESP32 2 | ==================================================================== 3 | 4 | This is a quick and dirty port of Nofrendo, a Nintendo Entertainment System emulator. It has basic sound support, but can emulate a NES at close to full speed, albeit with some framedrop due to the way the display is driven. 5 | 6 | Warning 7 | ------- 8 | 9 | This is a proof-of-concept and not an official application note. As such, this code is entirely unsupported by Espressif. 10 | 11 | 12 | Compiling 13 | --------- 14 | 15 | This code is an esp-idf project. You will need esp-idf to compile it. Newer versions of esp-idf may introduce incompatibilities with this code; 16 | for your reference. esp-idf test work well version: v3.3-rc-dirty 17 | 18 | Controller 19 | ---------- 20 | 21 | This emulator fully supports the Faces Gamepad kit: https://m5stack.com/collections/all/products/face 22 | 23 | ROM 24 | --- 25 | This NES emulator comes with a public domain ROM. If you want to use your own, please remember official nintendo roms are under copyright and the user bears the responsibility for any legal action. In order to upload a different rom change the 26 | .nes filename to the name of your rom in the flash.sh script in the firmware folder. Use esptool to flash the files to the device. 27 | 28 | Copyright 29 | --------- 30 | 31 | Code in this repository is Copyright (C) 2016 Espressif Systems, licensed under the Apache License 2.0 as described in the file LICENSE. Code in the 32 | components/nofrendo is Copyright (c) 1998-2000 Matthew Conte (matt@conte.com) and licensed under the GPLv2. 33 | 34 | -------------------------------------------------------------------------------- /components/nofrendo/intro.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** intro.h 21 | ** 22 | ** Nofrendo intro -- 6502 code 23 | ** $Id: intro.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _INTRO_H_ 27 | #define _INTRO_H_ 28 | 29 | #include 30 | 31 | extern void intro_get_header(rominfo_t *rominfo); 32 | extern int intro_get_rom(rominfo_t *rominfo); 33 | 34 | #endif /* !_INTRO_H_ */ 35 | 36 | /* 37 | ** $Log: intro.h,v $ 38 | ** Revision 1.2 2001/04/27 14:37:11 neil 39 | ** wheeee 40 | ** 41 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 42 | ** initial 43 | ** 44 | ** Revision 1.3 2000/10/25 00:23:16 matt 45 | ** makefiles updated for new directory structure 46 | ** 47 | ** Revision 1.2 2000/10/10 13:03:54 matt 48 | ** Mr. Clean makes a guest appearance 49 | ** 50 | ** Revision 1.1 2000/07/30 04:29:11 matt 51 | ** initial revision 52 | ** 53 | */ 54 | -------------------------------------------------------------------------------- /components/nofrendo/cpu/dis6502.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** dis6502.h 21 | ** 22 | ** 6502 disassembler header 23 | ** $Id: dis6502.h,v 1.1 2001/04/27 12:54:39 neil Exp $ 24 | */ 25 | 26 | #ifndef _DIS6502_H_ 27 | #define _DIS6502_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #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 | -------------------------------------------------------------------------------- /components/nofrendo/sndhrdw/fds_snd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** fds_snd.h 21 | ** 22 | ** Famicom Disk System sound emulation 23 | ** $Id: fds_snd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _FDS_SND_H_ 27 | #define _FDS_SND_H_ 28 | 29 | #include 30 | 31 | extern apuext_t fds_ext; 32 | 33 | 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 | -------------------------------------------------------------------------------- /components/nofrendo/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** log.h 21 | ** 22 | ** Error logging header file 23 | ** $Id: log.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _LOG_H_ 27 | #define _LOG_H_ 28 | 29 | #include 30 | 31 | extern int log_init(void); 32 | extern void log_shutdown(void); 33 | extern int log_print(const char *string); 34 | extern int log_printf(const char *format, ...); 35 | extern void log_chain_logfunc(int (*logfunc)(const char *string)); 36 | extern void log_assert(int expr, int line, const char *file, char *msg); 37 | 38 | #endif /* _LOG_H_ */ 39 | 40 | /* 41 | ** $Log: log.h,v $ 42 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 43 | ** initial 44 | ** 45 | ** Revision 1.7 2000/11/06 02:15:07 matt 46 | ** more robust logging routines 47 | ** 48 | ** Revision 1.6 2000/10/10 13:03:54 matt 49 | ** Mr. Clean makes a guest appearance 50 | ** 51 | ** Revision 1.5 2000/07/17 01:52:27 matt 52 | ** made sure last line of all source files is a newline 53 | ** 54 | ** Revision 1.4 2000/06/09 15:12:25 matt 55 | ** initial revision 56 | ** 57 | */ 58 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map000.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map0.c 21 | ** 22 | ** mapper 0 interface 23 | ** $Id: map000.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | mapintf_t map0_intf = 30 | { 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 | -------------------------------------------------------------------------------- /components/nofrendo/gui_elem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** gui_elem.h 21 | ** 22 | ** GUI elements (font, mouse pointer, etc.) 23 | ** $Id: gui_elem.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _GUI_ELEM_H_ 27 | #define _GUI_ELEM_H_ 28 | 29 | typedef struct fontchar_s 30 | { 31 | uint8 lines[6]; 32 | uint8 spacing; 33 | } fontchar_t; 34 | 35 | typedef struct font_s 36 | { 37 | const fontchar_t *character; 38 | uint8 height; 39 | } font_t; 40 | 41 | extern font_t small; 42 | 43 | #define CURSOR_WIDTH 11 44 | #define CURSOR_HEIGHT 19 45 | 46 | extern const uint8 cursor_color[]; 47 | extern const uint8 cursor[]; 48 | 49 | #endif /* _GUI_ELEM_H_ */ 50 | 51 | /* 52 | ** $Log: gui_elem.h,v $ 53 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 54 | ** initial 55 | ** 56 | ** Revision 1.7 2000/10/10 13:03:54 matt 57 | ** Mr. Clean makes a guest appearance 58 | ** 59 | ** Revision 1.6 2000/07/31 04:28:46 matt 60 | ** one million cleanups 61 | ** 62 | ** Revision 1.5 2000/07/17 01:52:27 matt 63 | ** made sure last line of all source files is a newline 64 | ** 65 | ** Revision 1.4 2000/06/09 15:12:25 matt 66 | ** initial revision 67 | ** 68 | */ 69 | -------------------------------------------------------------------------------- /components/nofrendo/nes/nesstate.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nesstate.h 21 | ** 22 | ** state saving header 23 | ** $Id: nesstate.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _NESSTATE_H_ 27 | #define _NESSTATE_H_ 28 | 29 | #include 30 | 31 | extern void state_setslot(int slot); 32 | extern int state_load(); 33 | extern int state_save(); 34 | 35 | #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 | -------------------------------------------------------------------------------- /components/nofrendo/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** version.h 21 | ** 22 | ** Program name / version definitions 23 | ** $Id: version.h,v 1.2 2001/05/05 16:50:49 neil Exp $ 24 | */ 25 | 26 | #ifndef _VERSION_H_ 27 | #define _VERSION_H_ 28 | 29 | #ifdef NSF_PLAYER 30 | #define APP_STRING "Nosefart" 31 | #else 32 | #define APP_STRING "Nofrendo" 33 | #endif /* NSF_PLAYER */ 34 | 35 | #define APP_VERSION "2.0" 36 | 37 | #endif /* _VERSION_H_ */ 38 | 39 | /* 40 | ** $Log: version.h,v $ 41 | ** Revision 1.2 2001/05/05 16:50:49 neil 42 | ** preparing for distribution 43 | ** 44 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 45 | ** initial 46 | ** 47 | ** Revision 1.9 2000/07/31 04:28:47 matt 48 | ** one million cleanups 49 | ** 50 | ** Revision 1.8 2000/07/17 01:52:28 matt 51 | ** made sure last line of all source files is a newline 52 | ** 53 | ** Revision 1.7 2000/07/04 04:46:55 matt 54 | ** updated version number 55 | ** 56 | ** Revision 1.6 2000/06/20 00:03:39 matt 57 | ** updated for 1.91 58 | ** 59 | ** Revision 1.5 2000/06/09 17:01:56 matt 60 | ** changed version to 1.90 61 | ** 62 | ** Revision 1.4 2000/06/09 15:12:25 matt 63 | ** initial revision 64 | ** 65 | */ 66 | -------------------------------------------------------------------------------- /components/nofrendo/nes/nes_pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nes_pal.h 21 | ** 22 | ** NES palette definition 23 | ** $Id: nes_pal.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _NESPAL_H_ 27 | #define _NESPAL_H_ 28 | 29 | extern rgb_t nes_palette[]; 30 | extern rgb_t shady_palette[]; 31 | 32 | extern void pal_generate(void); 33 | 34 | /* TODO: these are temporary hacks */ 35 | extern void pal_dechue(void); 36 | extern void pal_inchue(void); 37 | extern void pal_dectint(void); 38 | extern void pal_inctint(void); 39 | 40 | #endif /* _NESPAL_H_ */ 41 | 42 | /* 43 | ** $Log: nes_pal.h,v $ 44 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 45 | ** initial 46 | ** 47 | ** Revision 1.1 2000/10/24 12:20:28 matt 48 | ** changed directory structure 49 | ** 50 | ** Revision 1.8 2000/07/31 04:27:59 matt 51 | ** one million cleanups 52 | ** 53 | ** Revision 1.7 2000/07/21 04:20:35 matt 54 | ** added some nasty externs 55 | ** 56 | ** Revision 1.6 2000/07/10 13:49:32 matt 57 | ** renamed my palette and extern'ed it 58 | ** 59 | ** Revision 1.5 2000/07/05 17:14:34 neil 60 | ** Linux: Act Two, Scene One 61 | ** 62 | ** Revision 1.4 2000/06/09 15:12:26 matt 63 | ** initial revision 64 | ** 65 | */ 66 | -------------------------------------------------------------------------------- /components/nofrendo/sndhrdw/mmc5_snd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** mmc5_snd.h 21 | ** 22 | ** Nintendo MMC5 sound emulation header 23 | ** $Id: mmc5_snd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _MMC5_SND_H_ 27 | #define _MMC5_SND_H_ 28 | 29 | #include 30 | 31 | extern apuext_t mmc5_ext; 32 | 33 | #endif /* !_MMC5_SND_H_ */ 34 | 35 | /* 36 | ** $Log: mmc5_snd.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1 2001/04/27 12:54:40 neil 41 | ** blah 42 | ** 43 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 44 | ** initial 45 | ** 46 | ** Revision 1.2 2000/11/13 00:57:08 matt 47 | ** doesn't look as nasty now 48 | ** 49 | ** Revision 1.1 2000/10/24 12:19:59 matt 50 | ** changed directory structure 51 | ** 52 | ** Revision 1.6 2000/10/10 13:58:18 matt 53 | ** stroustrup squeezing his way in the door 54 | ** 55 | ** Revision 1.5 2000/09/27 12:26:03 matt 56 | ** changed sound accumulators back to floats 57 | ** 58 | ** Revision 1.4 2000/09/15 13:38:40 matt 59 | ** changes for optimized apu core 60 | ** 61 | ** Revision 1.3 2000/07/17 01:52:31 matt 62 | ** made sure last line of all source files is a newline 63 | ** 64 | ** Revision 1.2 2000/06/20 04:06:16 matt 65 | ** migrated external sound definition to apu module 66 | ** 67 | ** Revision 1.1 2000/06/20 00:06:47 matt 68 | ** initial revision 69 | ** 70 | */ 71 | -------------------------------------------------------------------------------- /components/nofrendo/sndhrdw/vrcvisnd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** vrcvisnd.h 21 | ** 22 | ** VRCVI (Konami MMC) sound hardware emulation header 23 | ** $Id: vrcvisnd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _VRCVISND_H_ 27 | #define _VRCVISND_H_ 28 | 29 | #include 30 | 31 | extern apuext_t vrcvi_ext; 32 | 33 | #endif /* _VRCVISND_H_ */ 34 | 35 | /* 36 | ** $Log: vrcvisnd.h,v $ 37 | ** Revision 1.2 2001/04/27 14:37:11 neil 38 | ** wheeee 39 | ** 40 | ** Revision 1.1 2001/04/27 12:54:40 neil 41 | ** blah 42 | ** 43 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 44 | ** initial 45 | ** 46 | ** Revision 1.1 2000/10/24 12:20:00 matt 47 | ** changed directory structure 48 | ** 49 | ** Revision 1.10 2000/09/27 12:26:03 matt 50 | ** changed sound accumulators back to floats 51 | ** 52 | ** Revision 1.9 2000/09/15 13:38:40 matt 53 | ** changes for optimized apu core 54 | ** 55 | ** Revision 1.8 2000/07/17 01:52:31 matt 56 | ** made sure last line of all source files is a newline 57 | ** 58 | ** Revision 1.7 2000/06/20 04:06:16 matt 59 | ** migrated external sound definition to apu module 60 | ** 61 | ** Revision 1.6 2000/06/20 00:08:58 matt 62 | ** changed to driver based API 63 | ** 64 | ** Revision 1.5 2000/06/09 16:49:02 matt 65 | ** removed all floating point from sound generation 66 | ** 67 | ** Revision 1.4 2000/06/09 15:12:28 matt 68 | ** initial revision 69 | ** 70 | */ 71 | -------------------------------------------------------------------------------- /components/nofrendo/nofconfig.h: -------------------------------------------------------------------------------- 1 | /* Nofrendo Configuration API 2 | ** 3 | ** This file is in the public domain. 4 | ** 5 | ** $Id: nofconfig.h,v 1.1 2001/04/27 14:37:11 neil Exp $ 6 | */ 7 | 8 | #ifndef _CONFIG_H_ 9 | #define _CONFIG_H_ 10 | 11 | #ifndef CONFIG_FILE 12 | #define CONFIG_FILE "nofrendo.cfg" 13 | #endif 14 | 15 | typedef struct config_s 16 | { 17 | /* open loads from the disk the saved configuration. 18 | ** 19 | ** open must be the first config function called. 20 | ** 21 | ** open returns true on success, false otherwise. 22 | */ 23 | bool (*open)(void); 24 | 25 | /* close saves the current configuration to disk. 26 | ** 27 | ** close must be the last config function called. 28 | */ 29 | void (*close)(void); 30 | 31 | /* read_int loads an integer from the configuration into "value" 32 | ** 33 | ** If the specified "key" does not exist, the "def"ault is returned 34 | */ 35 | int (*read_int)(const char *group, const char *key, int def); 36 | 37 | /* read_string copies a string from the configuration into "value" 38 | ** 39 | ** If the specified "key" does not exist, the "def"ault is returned 40 | */ 41 | const char *(*read_string)(const char *group, const char *key, const char *def); 42 | 43 | void (*write_int)(const char *group, const char *key, int value); 44 | void (*write_string)(const char *group, const char *key, const char *value); 45 | char *filename; 46 | } config_t; 47 | 48 | extern config_t config; 49 | 50 | #endif /* !_CONFIG_H_ */ 51 | 52 | /* 53 | ** $Log: nofconfig.h,v $ 54 | ** Revision 1.1 2001/04/27 14:37:11 neil 55 | ** wheeee 56 | ** 57 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 58 | ** initial 59 | ** 60 | ** Revision 1.5 2000/10/10 13:58:13 matt 61 | ** stroustrup squeezing his way in the door 62 | ** 63 | ** Revision 1.4 2000/07/19 15:58:55 neil 64 | ** config file now configurable (ha) 65 | ** 66 | ** Revision 1.3 2000/07/11 14:59:27 matt 67 | ** minor cosmetics.. =) 68 | ** 69 | ** Revision 1.2 2000/07/11 13:35:38 bsittler 70 | ** Changed the config API, implemented config file "nofrendo.cfg". The 71 | ** GGI drivers use the group [GGI]. Visual= and Mode= keys are understood. 72 | ** 73 | ** Revision 1.1 2000/07/11 07:46:11 neil 74 | ** Initial commit 75 | ** 76 | ** 77 | */ 78 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map093.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map93.c 21 | ** 22 | ** mapper 93 interface 23 | ** $Id: map093.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static void map93_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | /* ($8000-$FFFF) D7-D4 = switch $8000-$BFFF D0: mirror */ 35 | mmc_bankrom(16, 0x8000, value >> 4); 36 | 37 | if (value & 1) 38 | ppu_mirror(0, 1, 0, 1); /* vert */ 39 | else 40 | ppu_mirror(0, 0, 1, 1); /* horiz */ 41 | } 42 | 43 | static map_memwrite map93_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map002.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map2.c 21 | ** 22 | ** mapper 2 interface 23 | ** $Id: map002.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 2: UNROM */ 30 | static void map2_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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map003.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map3.c 21 | ** 22 | ** mapper 3 interface 23 | ** $Id: map003.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 3: CNROM */ 30 | static void map3_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankvrom(8, 0x0000, value); 35 | } 36 | 37 | static map_memwrite map3_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map094.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map94.c 21 | ** 22 | ** mapper 94 interface 23 | ** $Id: map094.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 94: Senjou no Ookami */ 30 | static void map94_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | /* ($8000-$FFFF) D7-D2 = switch $8000-$BFFF */ 35 | mmc_bankrom(16, 0x8000, value >> 2); 36 | } 37 | 38 | static map_memwrite map94_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map099.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map99.c 21 | ** 22 | ** mapper 99 interface 23 | ** $Id: map099.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* Switch VROM for VS games */ 31 | static void map99_vromswitch(uint8 value) 32 | { 33 | int bank = (value & 0x04) >> 2; 34 | mmc_bankvrom(8, 0x0000, bank); 35 | } 36 | 37 | /* mapper 99: VS. System */ 38 | static void map99_init(void) 39 | { 40 | ppu_mirror(0, 1, 2, 3); 41 | ppu_setvromswitch(map99_vromswitch); 42 | } 43 | 44 | mapintf_t map99_intf = 45 | { 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map079.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map78.c 21 | ** 22 | ** mapper 78 interface 23 | ** $Id: map079.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 79: NINA-03/06 */ 30 | static void map79_write(uint32 address, uint8 value) 31 | { 32 | if ((address & 0x5100) == 0x4100) 33 | { 34 | mmc_bankrom(32, 0x8000, (value >> 3) & 1); 35 | mmc_bankvrom(8, 0x0000, value & 7); 36 | } 37 | } 38 | 39 | static void map79_init(void) 40 | { 41 | mmc_bankrom(32, 0x8000, 0); 42 | mmc_bankvrom(8, 0x0000, 0); 43 | } 44 | 45 | static map_memwrite map79_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/pcx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** pcx.h 21 | ** 22 | ** PCX format screen-saving routines 23 | ** $Id: pcx.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _PCX_H_ 27 | #define _PCX_H_ 28 | 29 | #include 30 | #include 31 | 32 | /* Got these out of ZSoft's document */ 33 | typedef struct pcxheader_s 34 | { 35 | uint8 Manufacturer __PACKED__; 36 | uint8 Version __PACKED__; 37 | uint8 Encoding __PACKED__; 38 | uint8 BitsPerPixel __PACKED__; 39 | uint16 Xmin __PACKED__; 40 | uint16 Ymin __PACKED__; 41 | uint16 Xmax __PACKED__; 42 | uint16 Ymax __PACKED__; 43 | uint16 HDpi __PACKED__; 44 | uint16 VDpi __PACKED__; 45 | uint8 Colormap[48] __PACKED__; 46 | uint8 Reserved __PACKED__; 47 | uint8 NPlanes __PACKED__; 48 | uint16 BytesPerLine __PACKED__; 49 | uint16 PaletteInfo __PACKED__; 50 | uint16 HscreenSize __PACKED__; 51 | uint16 VscreenSize __PACKED__; 52 | uint8 Filler[54] __PACKED__; 53 | } pcxheader_t; 54 | 55 | extern int pcx_write(char *filename, bitmap_t *bmp, rgb_t *pal); 56 | 57 | #endif /* _PCX_H_ */ 58 | 59 | /* 60 | ** $Log: pcx.h,v $ 61 | ** Revision 1.2 2001/04/27 14:37:11 neil 62 | ** wheeee 63 | ** 64 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 65 | ** initial 66 | ** 67 | ** Revision 1.8 2000/11/05 16:37:18 matt 68 | ** rolled rgb.h into bitmap.h 69 | ** 70 | ** Revision 1.7 2000/07/25 02:21:56 matt 71 | ** had forgotten some includes 72 | ** 73 | ** Revision 1.6 2000/07/17 01:52:27 matt 74 | ** made sure last line of all source files is a newline 75 | ** 76 | ** Revision 1.5 2000/06/26 04:55:13 matt 77 | ** changed routine name, big whoop 78 | ** 79 | ** Revision 1.4 2000/06/09 15:12:25 matt 80 | ** initial revision 81 | ** 82 | */ 83 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map066.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map66.c 21 | ** 22 | ** mapper 66 interface 23 | ** $Id: map066.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 66: GNROM */ 30 | static void map66_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(32, 0x8000, (value >> 4) & 3); 35 | mmc_bankvrom(8, 0x0000, value & 3); 36 | } 37 | 38 | static void map66_init(void) 39 | { 40 | mmc_bankrom(32, 0x8000, 0); 41 | mmc_bankvrom(8, 0x0000, 0); 42 | } 43 | 44 | 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map011.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map11.c 21 | ** 22 | ** mapper 11 interface 23 | ** $Id: map011.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 11: Color Dreams, Wisdom Tree */ 30 | static void map11_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(32, 0x8000, value & 0x0F); 35 | mmc_bankvrom(8, 0x0000, value >> 4); 36 | } 37 | 38 | static void map11_init(void) 39 | { 40 | mmc_bankrom(32, 0x8000, 0); 41 | mmc_bankvrom(8, 0x0000, 0); 42 | } 43 | 44 | static map_memwrite map11_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map008.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map8.c 21 | ** 22 | ** mapper 8 interface 23 | ** $Id: map008.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 8: FFE F3xxx -- what the hell uses this? */ 30 | static void map8_write(uint32 address, uint8 value) 31 | { 32 | UNUSED(address); 33 | 34 | mmc_bankrom(16, 0x8000, value >> 3); 35 | mmc_bankvrom(8, 0x0000, value & 7); 36 | } 37 | 38 | static void map8_init(void) 39 | { 40 | mmc_bankrom(16, 0x8000, 0); 41 | mmc_bankrom(16, 0xC000, 1); 42 | mmc_bankvrom(8, 0x0000, 0); 43 | } 44 | 45 | static map_memwrite map8_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map231.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map231.c 21 | ** 22 | ** mapper 231 interface 23 | ** $Id: map231.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper 231: NINA-07, used in Wally Bear and the NO! Gang */ 30 | 31 | static void map231_init(void) 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map087.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map087.c 21 | ** 22 | ** Mapper #87 (16K VROM switch) 23 | ** Implementation by Firebug 24 | ** $Id: map087.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 25 | ** 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | /******************************************/ 35 | /* Mapper #87 write handler ($6000-$7FFF) */ 36 | /******************************************/ 37 | static void map87_write (uint32 address, uint8 value) 38 | { 39 | /* Within range, address written to is irrelevant */ 40 | UNUSED (address); 41 | 42 | /* Very simple: 8K CHR page is selected by D1 */ 43 | if (value & 0x02) 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 | -------------------------------------------------------------------------------- /components/nofrendo/bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** bitmap.h 21 | ** 22 | ** Bitmap object defines / prototypes 23 | ** $Id: bitmap.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _BITMAP_H_ 27 | #define _BITMAP_H_ 28 | 29 | #include 30 | 31 | /* a bitmap rectangle */ 32 | typedef struct rect_s 33 | { 34 | int16 x, y; 35 | uint16 w, h; 36 | } rect_t; 37 | 38 | typedef struct rgb_s 39 | { 40 | int r, g, b; 41 | } rgb_t; 42 | 43 | typedef struct bitmap_s 44 | { 45 | int width, height, pitch; 46 | bool hardware; /* is data a hardware region? */ 47 | uint8 *data; /* protected */ 48 | uint8 *line[ZERO_LENGTH]; /* will hold line pointers */ 49 | } bitmap_t; 50 | 51 | extern void bmp_clear(const bitmap_t *bitmap, uint8 color); 52 | extern bitmap_t *bmp_create(int width, int height, int overdraw); 53 | extern bitmap_t *bmp_createhw(uint8 *addr, int width, int height, int pitch); 54 | extern void bmp_destroy(bitmap_t **bitmap); 55 | 56 | #endif /* _BITMAP_H_ */ 57 | 58 | /* 59 | ** $Log: bitmap.h,v $ 60 | ** Revision 1.2 2001/04/27 14:37:11 neil 61 | ** wheeee 62 | ** 63 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 64 | ** initial 65 | ** 66 | ** Revision 1.12 2000/11/05 16:37:18 matt 67 | ** rolled rgb.h into bitmap.h 68 | ** 69 | ** Revision 1.11 2000/10/10 13:58:13 matt 70 | ** stroustrup squeezing his way in the door 71 | ** 72 | ** Revision 1.10 2000/09/18 02:06:48 matt 73 | ** -pedantic is your friend 74 | ** 75 | ** Revision 1.9 2000/07/31 04:28:46 matt 76 | ** one million cleanups 77 | ** 78 | ** Revision 1.8 2000/07/24 04:31:43 matt 79 | ** pitch/data area on non-hw bitmaps get padded to 32-bit boundaries 80 | ** 81 | ** Revision 1.7 2000/07/17 01:52:27 matt 82 | ** made sure last line of all source files is a newline 83 | ** 84 | ** Revision 1.6 2000/07/09 14:43:01 matt 85 | ** pitch is now configurable for bmp_createhw() 86 | ** 87 | ** Revision 1.5 2000/07/06 16:46:57 matt 88 | ** added bmp_clear() routine 89 | ** 90 | ** Revision 1.4 2000/06/09 15:12:25 matt 91 | ** initial revision 92 | ** 93 | */ 94 | -------------------------------------------------------------------------------- /components/nofrendo/nofrendo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nofrendo.h (c) 1998-2000 Matthew Conte (matt@conte.com) 21 | ** (c) 2000 Neil Stevens (multivac@fcmail.com) 22 | ** 23 | ** Note: all architectures should call these functions 24 | ** 25 | ** $Id: nofrendo.h,v 1.2 2001/04/27 11:10:08 neil Exp $ 26 | */ 27 | 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map007.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map7.c 21 | ** 22 | ** mapper 7 interface 23 | ** $Id: map007.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /* mapper 7: AOROM */ 32 | static void map7_write(uint32 address, uint8 value) 33 | { 34 | int mirror; 35 | UNUSED(address); 36 | 37 | mmc_bankrom(32, 0x8000, value); 38 | mirror = (value & 0x10) >> 4; 39 | ppu_mirror(mirror, mirror, mirror, mirror); 40 | } 41 | 42 | static void map7_init(void) 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 | -------------------------------------------------------------------------------- /components/nofrendo/memguard.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** memguard.h 21 | ** 22 | ** memory allocation wrapper routines 23 | ** $Id: memguard.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _MEMGUARD_H_ 27 | #define _MEMGUARD_H_ 28 | 29 | #ifdef strdup 30 | #undef strdup 31 | #endif 32 | 33 | #ifdef NOFRENDO_DEBUG 34 | 35 | #define malloc(s) _my_malloc((s), __FILE__, __LINE__) 36 | #define free(d) _my_free((void **) &(d), __FILE__, __LINE__) 37 | #define strdup(s) _my_strdup((s), __FILE__, __LINE__) 38 | 39 | extern void *_my_malloc(int size, char *file, int line); 40 | extern void _my_free(void **data, char *file, int line); 41 | extern char *_my_strdup(const char *string, char *file, int line); 42 | 43 | #else /* !NORFRENDO_DEBUG */ 44 | 45 | /* Non-debugging versions of calls */ 46 | #define malloc(s) _my_malloc((s)) 47 | #define free(d) _my_free((void **) &(d)) 48 | #define strdup(s) _my_strdup((s)) 49 | 50 | extern void *_my_malloc(int size); 51 | extern void _my_free(void **data); 52 | extern char *_my_strdup(const char *string); 53 | 54 | #endif /* !NOFRENDO_DEBUG */ 55 | 56 | 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map034.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map34.c 21 | ** 22 | ** mapper 34 interface 23 | ** $Id: map034.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | static void map34_init(void) 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 | -------------------------------------------------------------------------------- /components/nofrendo/nes/nes_rom.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nes_rom.h 21 | ** 22 | ** NES ROM loading/saving related defines / prototypes 23 | ** $Id: nes_rom.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _NES_ROM_H_ 27 | #define _NES_ROM_H_ 28 | 29 | #include 30 | #include 31 | 32 | typedef enum 33 | { 34 | MIRROR_HORIZ = 0, 35 | MIRROR_VERT = 1 36 | } mirror_t; 37 | 38 | #define ROM_FLAG_BATTERY 0x01 39 | #define ROM_FLAG_TRAINER 0x02 40 | #define ROM_FLAG_FOURSCREEN 0x04 41 | #define ROM_FLAG_VERSUS 0x08 42 | 43 | typedef struct rominfo_s 44 | { 45 | /* pointers to ROM and VROM */ 46 | uint8 *rom, *vrom; 47 | 48 | /* pointers to SRAM and VRAM */ 49 | uint8 *sram, *vram; 50 | 51 | /* number of banks */ 52 | int rom_banks, vrom_banks; 53 | int sram_banks, vram_banks; 54 | 55 | int mapper_number; 56 | mirror_t mirror; 57 | 58 | uint8 flags; 59 | 60 | char filename[PATH_MAX + 1]; 61 | } rominfo_t; 62 | 63 | 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 | 69 | 70 | #endif /* _NES_ROM_H_ */ 71 | 72 | /* 73 | ** $Log: nes_rom.h,v $ 74 | ** Revision 1.2 2001/04/27 14:37:11 neil 75 | ** wheeee 76 | ** 77 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 78 | ** initial 79 | ** 80 | ** Revision 1.2 2000/10/25 01:23:08 matt 81 | ** basic system autodetection 82 | ** 83 | ** Revision 1.1 2000/10/24 12:20:28 matt 84 | ** changed directory structure 85 | ** 86 | ** Revision 1.11 2000/10/22 15:01:29 matt 87 | ** irrelevant mirroring modes removed 88 | ** 89 | ** Revision 1.10 2000/10/17 03:22:38 matt 90 | ** cleaning up rom module 91 | ** 92 | ** Revision 1.9 2000/10/10 13:58:13 matt 93 | ** stroustrup squeezing his way in the door 94 | ** 95 | ** Revision 1.8 2000/10/10 13:03:54 matt 96 | ** Mr. Clean makes a guest appearance 97 | ** 98 | ** Revision 1.7 2000/07/25 02:20:58 matt 99 | ** cleanups 100 | ** 101 | ** Revision 1.6 2000/07/19 15:59:39 neil 102 | ** PATH_MAX, strncpy, snprintf, and strncat are our friends 103 | ** 104 | ** Revision 1.5 2000/07/17 01:52:27 matt 105 | ** made sure last line of all source files is a newline 106 | ** 107 | ** Revision 1.4 2000/06/09 15:12:25 matt 108 | ** initial revision 109 | ** 110 | */ 111 | -------------------------------------------------------------------------------- /components/nofrendo/nes/nesinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** nesinput.h 21 | ** 22 | ** Platform independent input definitions 23 | ** $Id: nesinput.h,v 1.1.1.1 2001/04/27 07:03:54 neil Exp $ 24 | */ 25 | 26 | #ifndef _NESINPUT_H_ 27 | #define _NESINPUT_H_ 28 | 29 | /* NES control pad bitmasks */ 30 | #define INP_PAD_A 0x01 31 | #define INP_PAD_B 0x02 32 | #define INP_PAD_SELECT 0x04 33 | #define INP_PAD_START 0x08 34 | #define INP_PAD_UP 0x10 35 | #define INP_PAD_DOWN 0x20 36 | #define INP_PAD_LEFT 0x40 37 | #define INP_PAD_RIGHT 0x80 38 | 39 | #define INP_ZAPPER_HIT 0x00 40 | #define INP_ZAPPER_MISS 0x08 41 | #define INP_ZAPPER_TRIG 0x10 42 | 43 | #define INP_JOYPAD0 0x0001 44 | #define INP_JOYPAD1 0x0002 45 | #define INP_ZAPPER 0x0004 46 | #define INP_POWERPAD 0x0008 47 | #define INP_ARKANOID 0x0010 48 | #define INP_VSDIPSW0 0x0020 49 | #define INP_VSDIPSW1 0x0040 50 | 51 | /* upper byte is what's returned in D4, lower is D3 */ 52 | #define INP_PPAD_1 0x0002 53 | #define INP_PPAD_2 0x0001 54 | #define INP_PPAD_3 0x0200 55 | #define INP_PPAD_4 0x0100 56 | #define INP_PPAD_5 0x0004 57 | #define INP_PPAD_6 0x0010 58 | #define INP_PPAD_7 0x0080 59 | #define INP_PPAD_8 0x0800 60 | #define INP_PPAD_9 0x0008 61 | #define INP_PPAD_10 0x0020 62 | #define INP_PPAD_11 0x0040 63 | #define INP_PPAD_12 0x0400 64 | 65 | 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 | -------------------------------------------------------------------------------- /components/nofrendo/sndhrdw/fds_snd.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** fds_snd.c 21 | ** 22 | ** Famicom Disk System sound emulation 23 | ** $Id: fds_snd.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static int32 fds_incsize = 0; 31 | 32 | /* mix sound channels together */ 33 | static int32 fds_process(void) 34 | { 35 | int32 output; 36 | output = 0; 37 | 38 | return output; 39 | } 40 | 41 | /* write to registers */ 42 | static void fds_write(uint32 address, uint8 value) 43 | { 44 | UNUSED(address); 45 | UNUSED(value); 46 | } 47 | 48 | /* reset state of vrcvi sound channels */ 49 | static void fds_reset(void) 50 | { 51 | apu_t apu; 52 | 53 | apu_getcontext(&apu); 54 | // fds_incsize = apu.cycle_rate; 55 | fds_incsize = (int32) (APU_BASEFREQ * 65536.0 / (float) apu.sample_rate); 56 | } 57 | 58 | static apu_memwrite fds_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map032.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map32.c 21 | ** 22 | ** mapper 32 interface 23 | ** $Id: map032.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | static int select_c000 = 0; 31 | 32 | /* mapper 32: Irem G-101 */ 33 | static void map32_write(uint32 address, uint8 value) 34 | { 35 | switch (address >> 12) 36 | { 37 | case 0x08: 38 | if (select_c000) 39 | mmc_bankrom(8, 0xC000, value); 40 | else 41 | mmc_bankrom(8, 0x8000, value); 42 | break; 43 | 44 | case 0x09: 45 | if (value & 1) 46 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 47 | else 48 | ppu_mirror(0, 1, 0, 1); /* vertical */ 49 | 50 | select_c000 = (value & 0x02); 51 | break; 52 | 53 | case 0x0A: 54 | mmc_bankrom(8, 0xA000, value); 55 | break; 56 | 57 | case 0x0B: 58 | { 59 | int loc = (address & 0x07) << 10; 60 | mmc_bankvrom(1, loc, value); 61 | } 62 | break; 63 | 64 | default: 65 | break; 66 | } 67 | } 68 | 69 | static map_memwrite map32_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map078.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map78.c 21 | ** 22 | ** mapper 78 interface 23 | ** $Id: map078.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /* mapper 78: Holy Diver, Cosmo Carrier */ 31 | /* ($8000-$FFFF) D2-D0 = switch $8000-$BFFF */ 32 | /* ($8000-$FFFF) D7-D4 = switch PPU $0000-$1FFF */ 33 | /* ($8000-$FFFF) D3 = switch mirroring */ 34 | static void map78_write(uint32 address, uint8 value) 35 | { 36 | UNUSED(address); 37 | 38 | mmc_bankrom(16, 0x8000, value & 7); 39 | mmc_bankvrom(8, 0x0000, (value >> 4) & 0x0F); 40 | 41 | /* Ugh! Same abuse of the 4-screen bit as with Mapper #70 */ 42 | if (mmc_getinfo()->flags & ROM_FLAG_FOURSCREEN) 43 | { 44 | if (value & 0x08) 45 | ppu_mirror(0, 1, 0, 1); /* vert */ 46 | else 47 | ppu_mirror(0, 0, 1, 1); /* horiz */ 48 | } 49 | else 50 | { 51 | int mirror = (value >> 3) & 1; 52 | ppu_mirror(mirror, mirror, mirror, mirror); 53 | } 54 | } 55 | 56 | static map_memwrite map78_memwrite[] = 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 | -------------------------------------------------------------------------------- /components/nofrendo/noftypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** types.h 21 | ** 22 | ** Data type definitions 23 | ** $Id: noftypes.h,v 1.1 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _TYPES_H_ 27 | #define _TYPES_H_ 28 | 29 | /* Define this if running on little-endian (x86) systems */ 30 | #define HOST_LITTLE_ENDIAN 31 | 32 | #ifdef __GNUC__ 33 | #define INLINE static inline 34 | #define ZERO_LENGTH 0 35 | #elif defined(WIN32) 36 | #define INLINE static __inline 37 | #define ZERO_LENGTH 0 38 | #else /* crapintosh? */ 39 | #define INLINE static 40 | #define ZERO_LENGTH 1 41 | #endif 42 | 43 | /* quell stupid compiler warnings */ 44 | #define UNUSED(x) ((x) = (x)) 45 | 46 | typedef signed char int8; 47 | typedef signed short int16; 48 | typedef signed int int32; 49 | typedef unsigned char uint8; 50 | typedef unsigned short uint16; 51 | typedef unsigned int uint32; 52 | 53 | #ifndef __cplusplus 54 | typedef enum 55 | { 56 | false = 0, 57 | true = 1 58 | } bool; 59 | 60 | #ifndef NULL 61 | #define NULL ((void *) 0) 62 | #endif 63 | #endif /* !__cplusplus */ 64 | 65 | #include 66 | #include 67 | 68 | #ifdef NOFRENDO_DEBUG 69 | 70 | #define ASSERT(expr) log_assert((int) (expr), __LINE__, __FILE__, NULL) 71 | #define ASSERT_MSG(msg) log_assert(false, __LINE__, __FILE__, (msg)) 72 | 73 | #else /* !NOFRENDO_DEBUG */ 74 | 75 | #define ASSERT(expr) 76 | #define ASSERT_MSG(msg) 77 | 78 | #endif /* !NOFRENDO_DEBUG */ 79 | 80 | #endif /* _TYPES_H_ */ 81 | 82 | /* 83 | ** $Log: noftypes.h,v $ 84 | ** Revision 1.1 2001/04/27 14:37:11 neil 85 | ** wheeee 86 | ** 87 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 88 | ** initial 89 | ** 90 | ** Revision 1.15 2000/11/05 16:37:18 matt 91 | ** rolled rgb.h into bitmap.h 92 | ** 93 | ** Revision 1.14 2000/10/17 03:22:16 matt 94 | ** safe UNUSED 95 | ** 96 | ** Revision 1.13 2000/10/10 13:58:14 matt 97 | ** stroustrup squeezing his way in the door 98 | ** 99 | ** Revision 1.12 2000/10/10 13:03:54 matt 100 | ** Mr. Clean makes a guest appearance 101 | ** 102 | ** Revision 1.11 2000/08/11 01:44:05 matt 103 | ** cosmeses 104 | ** 105 | ** Revision 1.10 2000/07/31 04:28:47 matt 106 | ** one million cleanups 107 | ** 108 | ** Revision 1.9 2000/07/24 04:30:17 matt 109 | ** ASSERTs should have been calling log_shutdown 110 | ** 111 | ** Revision 1.8 2000/07/17 01:52:28 matt 112 | ** made sure last line of all source files is a newline 113 | ** 114 | ** Revision 1.7 2000/07/04 04:46:44 matt 115 | ** moved INLINE define from osd.h 116 | ** 117 | ** Revision 1.6 2000/06/09 15:12:25 matt 118 | ** initial revision 119 | ** 120 | */ 121 | -------------------------------------------------------------------------------- /components/nofrendo/nes/mmclist.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** mmclist.c 21 | ** 22 | ** list of all mapper interfaces 23 | ** $Id: mmclist.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* mapper interfaces */ 30 | extern mapintf_t map0_intf; 31 | extern mapintf_t map1_intf; 32 | extern mapintf_t map2_intf; 33 | extern mapintf_t map3_intf; 34 | extern mapintf_t map4_intf; 35 | extern mapintf_t map5_intf; 36 | extern mapintf_t map7_intf; 37 | extern mapintf_t map8_intf; 38 | extern mapintf_t map9_intf; 39 | extern mapintf_t 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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map229.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 | ** 4 | ** 5 | ** This program is free software; you can redistribute it and/or 6 | ** modify it under the terms of version 2 of the GNU Library General 7 | ** Public License as published by the Free Software Foundation. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | ** Library General Public License for more details. To obtain a 13 | ** copy of the GNU Library General Public License, write to the Free 14 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | ** 16 | ** Any permitted reproduction of these routines, in whole or in part, 17 | ** must bear this legend. 18 | ** 19 | ** 20 | ** map229.c 21 | ** 22 | ** Mapper #229 (31 in 1) 23 | ** Implementation by Firebug 24 | ** Mapper information courtesy of Mark Knibbs 25 | ** $Id: map229.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 26 | ** 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /************************/ 36 | /* Mapper #229: 31 in 1 */ 37 | /************************/ 38 | static void map229_init (void) 39 | { 40 | /* On reset, PRG is set to first 32K and CHR to first 8K */ 41 | mmc_bankrom (32, 0x8000, 0x00); 42 | mmc_bankvrom (8, 0x0000, 0x00); 43 | 44 | /* Done */ 45 | return; 46 | } 47 | 48 | /*******************************************/ 49 | /* Mapper #229 write handler ($8000-$FFFF) */ 50 | /*******************************************/ 51 | static void map229_write (uint32 address, uint8 value) 52 | { 53 | /* Value written is irrelevant */ 54 | UNUSED (value); 55 | 56 | /* A4-A0 sets 8K CHR page */ 57 | mmc_bankvrom (8, 0x0000, (uint8) (address & 0x1F)); 58 | 59 | /* If A4-A1 are all low then select the first 32K, */ 60 | /* otherwise select a 16K bank at both $8000 and $C000 */ 61 | if ((address & 0x1E) == 0x00) 62 | { 63 | mmc_bankrom (32, 0x8000, 0x00); 64 | } 65 | else 66 | { 67 | mmc_bankrom (16, 0x8000, (uint8) (address & 0x1F)); 68 | mmc_bankrom (16, 0xC000, (uint8) (address & 0x1F)); 69 | } 70 | 71 | /* A5: mirroring (low = vertical, high = horizontal) */ 72 | if (address & 0x20) 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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo-esp32/i2c_keyboard.c: -------------------------------------------------------------------------------- 1 | /* i2c - Example 2 | 3 | For other examples please check: 4 | https://github.com/espressif/esp-idf/tree/master/examples 5 | 6 | This example code is in the Public Domain (or CC0 licensed, at your option.) 7 | 8 | Unless required by applicable law or agreed to in writing, this 9 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 10 | CONDITIONS OF ANY KIND, either express or implied. 11 | */ 12 | #include "i2c_keyboard.h" 13 | 14 | #define DATA_LENGTH 512 /*! 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 | -------------------------------------------------------------------------------- /components/nofrendo-esp32/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "Nofrendo ESP32-specific configuration" 2 | 3 | choice NOFRENDO_HARDWARE 4 | prompt "Hardware to run on" 5 | default ESP_WROVER_KIT_V2_ILI 6 | help 7 | This emulator can run on various types of hardware. Select what you have here. 8 | 9 | config HW_WROVERKIT_V1 10 | bool "ESP_Wrover_Kit v1 (red PCB)" 11 | 12 | config HW_WROVERKIT_V2 13 | bool "ESP_Wrover_Kit v2 (black PCB)" 14 | 15 | config HW_CUSTOM 16 | bool "Custom hardware" 17 | 18 | endchoice 19 | 20 | choice HW_LCD_TYPE_SEL 21 | prompt "LCD type" 22 | depends on HW_CUSTOM || HW_WROVERKIT_V2 23 | 24 | config HW_LCD_TYPE_ILI 25 | bool "ILI9341 LCD" 26 | 27 | config HW_LCD_TYPE_ST 28 | bool "ST7789V LCD" 29 | 30 | endchoice 31 | 32 | config HW_WROVERKIT 33 | bool 34 | default n if HW_CUSTOM 35 | default y if HW_WROVERKIT_V1 36 | default y if HW_WROVERKIT_V2 37 | 38 | 39 | config HW_LCD_TYPE 40 | int 41 | default 0 if HW_WROVERKIT_V1 42 | default 0 if HW_LCD_TYPE_ILI 43 | default 1 if HW_LCD_TYPE_ST 44 | 45 | config HW_LCD_MISO_GPIO_CUST 46 | int "LCD MISO pin" 47 | depends on HW_CUSTOM 48 | range 1 35 49 | default 25 50 | 51 | config HW_LCD_MOSI_GPIO_CUST 52 | int "LCD MOSI pin" 53 | depends on HW_CUSTOM 54 | range 1 35 55 | default 23 56 | 57 | config HW_LCD_CLK_GPIO_CUST 58 | int "LCD CLK pin" 59 | depends on HW_CUSTOM 60 | range 1 35 61 | default 19 62 | 63 | config HW_LCD_CS_GPIO_CUST 64 | int "LCD CS pin" 65 | depends on HW_CUSTOM 66 | range 1 35 67 | default 22 68 | 69 | config HW_LCD_DC_GPIO_CUST 70 | int "LCD DC pin" 71 | depends on HW_CUSTOM 72 | range 1 35 73 | default 21 74 | 75 | config HW_LCD_RESET_GPIO_CUST 76 | int "LCD RESET pin" 77 | depends on HW_CUSTOM 78 | range 1 35 79 | default 18 80 | 81 | config HW_LCD_BL_GPIO_CUST 82 | int "LCD Backlight Enable pin" 83 | depends on HW_CUSTOM 84 | range 1 35 85 | default 5 86 | 87 | config HW_INV_BL_CUST 88 | bool "Invert backlight output" 89 | default n 90 | depends on HW_CUSTOM 91 | 92 | 93 | config HW_INV_BL 94 | bool 95 | default HW_INBV_BL_CUST if HW_CUSTOM 96 | default n if HW_WROVERKIT_V1 97 | default y if HW_WROVERKIT_V2 98 | 99 | config HW_LCD_MISO_GPIO 100 | int 101 | default HW_LCD_MISO_GPIO_CUST if HW_CUSTOM 102 | default 25 if HW_WROVERKIT 103 | 104 | config HW_LCD_MOSI_GPIO 105 | int 106 | default HW_LCD_MOSI_GPIO_CUST if HW_CUSTOM 107 | default 23 if HW_WROVERKIT 108 | 109 | config HW_LCD_CLK_GPIO 110 | int 111 | default HW_LCD_CLK_GPIO_CUST if HW_CUSTOM 112 | default 19 if HW_WROVERKIT 113 | 114 | config HW_LCD_CS_GPIO 115 | int 116 | default HW_LCD_CS_GPIO_CUST if HW_CUSTOM 117 | default 22 if HW_WROVERKIT 118 | 119 | config HW_LCD_DC_GPIO 120 | int 121 | default HW_LCD_DC_GPIO_CUST if HW_CUSTOM 122 | default 21 if HW_WROVERKIT 123 | 124 | config HW_LCD_RESET_GPIO 125 | int 126 | default HW_LCD_RESET_GPIO_CUST if HW_CUSTOM 127 | default 18 if HW_WROVERKIT 128 | 129 | config HW_LCD_BL_GPIO 130 | int 131 | default HW_LCD_BL_GPIO_CUST if HW_CUSTOM 132 | default 5 if HW_WROVERKIT 133 | 134 | 135 | config SOUND_ENA 136 | bool "Analog audio on GPIO26" 137 | default n 138 | help 139 | ESP32 will output 0-3.3V analog audio signal on GPIO26. 140 | 141 | 142 | config HW_PSX_ENA 143 | bool "Enable PSX controller input" 144 | default y 145 | help 146 | If you connect a PSX/PS2 controller to the following GPIOs, you can control the NES. 147 | 148 | 149 | config HW_PSX_CLK 150 | int "PSX controller CLK GPIO pin" 151 | depends on HW_PSX_ENA 152 | range 1 35 153 | default 14 154 | 155 | config HW_PSX_DAT 156 | int "PSX controller DATa GPIO pin" 157 | depends on HW_PSX_ENA 158 | range 1 35 159 | default 27 160 | 161 | config HW_PSX_ATT 162 | int "PSX controller ATTention GPIO pin" 163 | depends on HW_PSX_ENA 164 | range 1 35 165 | default 16 166 | 167 | config HW_PSX_CMD 168 | int "PSX controller CoMmanD GPIO pin" 169 | depends on HW_PSX_ENA 170 | range 1 35 171 | default 2 172 | 173 | endmenu -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | void (*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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/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 | -------------------------------------------------------------------------------- /components/nofrendo/osd.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 | ** osd.h 21 | ** 22 | ** O/S dependent routine defintions (must be customized) 23 | ** $Id: osd.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 | */ 25 | 26 | #ifndef _OSD_H_ 27 | #define _OSD_H_ 28 | 29 | #include 30 | #ifndef PATH_MAX 31 | #define PATH_MAX 512 32 | #endif /* PATH_MAX */ 33 | 34 | #ifdef __GNUC__ 35 | #define __PACKED__ __attribute__ ((packed)) 36 | 37 | #ifdef __DJGPP__ 38 | #define PATH_SEP '\\' 39 | #else /* !__DJGPP__ */ 40 | #define PATH_SEP '/' 41 | #endif /* !__DJGPP__ */ 42 | 43 | #elif defined(WIN32) 44 | #define __PACKED__ 45 | #define PATH_SEP '\\' 46 | #else /* !defined(WIN32) && !__GNUC__ */ 47 | #define __PACKED__ 48 | #define PATH_SEP ':' 49 | #endif /* !defined(WIN32) && !__GNUC__ */ 50 | 51 | #if !defined(WIN32) && !defined(__DJGPP__) 52 | #define stricmp strcasecmp 53 | #endif /* !WIN32 && !__DJGPP__ */ 54 | 55 | 56 | extern void osd_setsound(void (*playfunc)(void *buffer, int size)); 57 | 58 | 59 | #ifndef NSF_PLAYER 60 | #include 61 | #include 62 | 63 | typedef struct vidinfo_s 64 | { 65 | int default_width, default_height; 66 | viddriver_t *driver; 67 | } vidinfo_t; 68 | 69 | typedef struct sndinfo_s 70 | { 71 | int sample_rate; 72 | int bps; 73 | } sndinfo_t; 74 | 75 | /* get info */ 76 | extern void osd_getvideoinfo(vidinfo_t *info); 77 | extern void osd_getsoundinfo(sndinfo_t *info); 78 | 79 | /* init / shutdown */ 80 | extern int osd_init(void); 81 | extern void osd_shutdown(void); 82 | extern int osd_main(int argc, char *argv[]); 83 | 84 | extern int osd_installtimer(int frequency, void *func, int funcsize, 85 | void *counter, int countersize); 86 | 87 | /* filename manipulation */ 88 | extern void osd_fullname(char *fullname, const char *shortname); 89 | extern char *osd_newextension(char *string, char *ext); 90 | 91 | /* input */ 92 | extern void osd_getinput(void); 93 | extern void osd_getmouse(int *x, int *y, int *button); 94 | 95 | /* build a filename for a snapshot, return -ve for error */ 96 | extern int osd_makesnapname(char *filename, int len); 97 | 98 | #endif /* !NSF_PLAYER */ 99 | 100 | #endif /* _OSD_H_ */ 101 | 102 | /* 103 | ** $Log: osd.h,v $ 104 | ** Revision 1.2 2001/04/27 14:37:11 neil 105 | ** wheeee 106 | ** 107 | ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 108 | ** initial 109 | ** 110 | ** Revision 1.30 2000/11/05 22:53:13 matt 111 | ** only one video driver per system, please 112 | ** 113 | ** Revision 1.29 2000/11/05 06:23:41 matt 114 | ** thinlib spawns changes 115 | ** 116 | ** Revision 1.28 2000/10/22 19:15:39 matt 117 | ** more sane timer ISR / autoframeskip 118 | ** 119 | ** Revision 1.27 2000/10/21 19:25:59 matt 120 | ** many more cleanups 121 | ** 122 | ** Revision 1.26 2000/10/10 13:03:53 matt 123 | ** Mr. Clean makes a guest appearance 124 | ** 125 | ** Revision 1.25 2000/10/02 15:01:12 matt 126 | ** frag size has been removed 127 | ** 128 | ** Revision 1.24 2000/08/31 02:40:18 matt 129 | ** fixed some crap 130 | ** 131 | ** Revision 1.23 2000/08/16 02:57:14 matt 132 | ** changed video interface a wee bit 133 | ** 134 | ** Revision 1.22 2000/08/11 01:46:30 matt 135 | ** new OSD sound information interface 136 | ** 137 | ** Revision 1.21 2000/08/04 15:01:32 neil 138 | ** BeOS cleanups 139 | ** 140 | ** Revision 1.20 2000/08/04 14:36:14 neil 141 | ** BeOS is working.. kinda 142 | ** 143 | ** Revision 1.19 2000/07/26 21:36:13 neil 144 | ** Big honkin' change -- see the mailing list 145 | ** 146 | ** Revision 1.18 2000/07/23 16:21:35 neil 147 | ** neither stricmp nor strcasecmp works everywhere 148 | ** 149 | ** Revision 1.17 2000/07/23 15:17:40 matt 150 | ** osd_getfragsize 151 | ** 152 | ** Revision 1.16 2000/07/21 13:37:20 neil 153 | ** snap filenames are OS-dependent 154 | ** 155 | ** Revision 1.15 2000/07/21 04:58:37 matt 156 | ** new osd_main structure 157 | ** 158 | ** Revision 1.14 2000/07/21 04:26:15 matt 159 | ** added some nasty externs 160 | ** 161 | ** Revision 1.13 2000/07/21 02:42:45 matt 162 | ** merged osd_getinput and osd_gethostinput 163 | ** 164 | ** Revision 1.12 2000/07/19 13:10:35 neil 165 | ** PATH_MAX 166 | ** 167 | ** Revision 1.11 2000/07/10 03:04:15 matt 168 | ** removed scanlines, backbuffer from custom blit 169 | ** 170 | ** Revision 1.10 2000/07/06 16:48:25 matt 171 | ** new video driver 172 | ** 173 | ** Revision 1.9 2000/07/05 17:26:16 neil 174 | ** Moved the externs in nofrendo.c to osd.h 175 | ** 176 | ** Revision 1.8 2000/07/04 23:07:06 matt 177 | ** djgpp path separator bugfix 178 | ** 179 | ** Revision 1.7 2000/07/04 04:45:33 matt 180 | ** moved INLINE define into types.h 181 | ** 182 | ** Revision 1.6 2000/06/29 16:06:18 neil 183 | ** Wrapped DOS-specific headers in an ifdef 184 | ** 185 | ** Revision 1.5 2000/06/09 15:12:25 matt 186 | ** initial revision 187 | ** 188 | */ 189 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map009.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 | ** map9.c 21 | ** 22 | ** mapper 9 interface 23 | ** $Id: map009.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 | static uint8 latch[2]; 33 | static uint8 regs[4]; 34 | 35 | /* Used when tile $FD/$FE is accessed */ 36 | static void mmc9_latchfunc(uint32 address, uint8 value) 37 | { 38 | if (0xFD == value || 0xFE == value) 39 | { 40 | int reg; 41 | 42 | if (address) 43 | { 44 | latch[1] = value; 45 | reg = 2 + (value - 0xFD); 46 | } 47 | else 48 | { 49 | latch[0] = value; 50 | reg = value - 0xFD; 51 | } 52 | 53 | mmc_bankvrom(4, address, regs[reg]); 54 | } 55 | } 56 | 57 | /* mapper 9: MMC2 */ 58 | /* MMC2: Punch-Out! */ 59 | static void map9_write(uint32 address, uint8 value) 60 | { 61 | switch ((address & 0xF000) >> 12) 62 | { 63 | case 0xA: 64 | mmc_bankrom(8, 0x8000, value); 65 | break; 66 | 67 | case 0xB: 68 | regs[0] = value; 69 | if (0xFD == latch[0]) 70 | mmc_bankvrom(4, 0x0000, value); 71 | break; 72 | 73 | case 0xC: 74 | regs[1] = value; 75 | if (0xFE == latch[0]) 76 | mmc_bankvrom(4, 0x0000, value); 77 | break; 78 | 79 | case 0xD: 80 | regs[2] = value; 81 | if (0xFD == latch[1]) 82 | mmc_bankvrom(4, 0x1000, value); 83 | break; 84 | 85 | case 0xE: 86 | regs[3] = value; 87 | if (0xFE == latch[1]) 88 | mmc_bankvrom(4, 0x1000, value); 89 | break; 90 | 91 | case 0xF: 92 | if (value & 1) 93 | ppu_mirror(0, 0, 1, 1); /* horizontal */ 94 | else 95 | ppu_mirror(0, 1, 0, 1); /* vertical */ 96 | break; 97 | 98 | default: 99 | break; 100 | } 101 | } 102 | 103 | static void map9_init(void) 104 | { 105 | memset(regs, 0, sizeof(regs)); 106 | 107 | mmc_bankrom(8, 0x8000, 0); 108 | mmc_bankrom(8, 0xA000, (mmc_getinfo()->rom_banks * 2) - 3); 109 | mmc_bankrom(8, 0xC000, (mmc_getinfo()->rom_banks * 2) - 2); 110 | mmc_bankrom(8, 0xE000, (mmc_getinfo()->rom_banks * 2) - 1); 111 | 112 | latch[0] = 0xFE; 113 | latch[1] = 0xFE; 114 | 115 | ppu_setlatchfunc(mmc9_latchfunc); 116 | } 117 | 118 | static void map9_getstate(SnssMapperBlock *state) 119 | { 120 | state->extraData.mapper9.latch[0] = latch[0]; 121 | state->extraData.mapper9.latch[1] = latch[1]; 122 | state->extraData.mapper9.lastB000Write = regs[0]; 123 | state->extraData.mapper9.lastC000Write = regs[1]; 124 | state->extraData.mapper9.lastD000Write = regs[2]; 125 | state->extraData.mapper9.lastE000Write = regs[3]; 126 | } 127 | 128 | static void map9_setstate(SnssMapperBlock *state) 129 | { 130 | latch[0] = state->extraData.mapper9.latch[0]; 131 | latch[1] = state->extraData.mapper9.latch[1]; 132 | regs[0] = state->extraData.mapper9.lastB000Write; 133 | regs[1] = state->extraData.mapper9.lastC000Write; 134 | regs[2] = state->extraData.mapper9.lastD000Write; 135 | regs[3] = state->extraData.mapper9.lastE000Write; 136 | } 137 | 138 | static map_memwrite map9_memwrite[] = 139 | { 140 | { 0x8000, 0xFFFF, map9_write }, 141 | { -1, -1, NULL } 142 | }; 143 | 144 | mapintf_t map9_intf = 145 | { 146 | 9, /* mapper number */ 147 | "MMC2", /* mapper name */ 148 | map9_init, /* init routine */ 149 | NULL, /* vblank callback */ 150 | NULL, /* hblank callback */ 151 | map9_getstate, /* get state (snss) */ 152 | map9_setstate, /* set state (snss) */ 153 | NULL, /* memory read structure */ 154 | map9_memwrite, /* memory write structure */ 155 | NULL /* external sound device */ 156 | }; 157 | 158 | /* 159 | ** $Log: map009.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.1.1 2001/04/27 07:03:54 neil 167 | ** initial 168 | ** 169 | ** Revision 1.1 2000/10/24 12:19:33 matt 170 | ** changed directory structure 171 | ** 172 | ** Revision 1.9 2000/10/22 19:17:46 matt 173 | ** mapper cleanups galore 174 | ** 175 | ** Revision 1.8 2000/10/22 15:03:14 matt 176 | ** simplified mirroring 177 | ** 178 | ** Revision 1.7 2000/10/21 19:33:38 matt 179 | ** many more cleanups 180 | ** 181 | ** Revision 1.6 2000/07/17 05:11:35 matt 182 | ** minor update from making PPU code less filthy 183 | ** 184 | ** Revision 1.5 2000/07/15 23:52:19 matt 185 | ** rounded out a bunch more mapper interfaces 186 | ** 187 | ** Revision 1.4 2000/07/10 05:29:03 matt 188 | ** cleaned up some mirroring issues 189 | ** 190 | ** Revision 1.3 2000/07/06 02:48:43 matt 191 | ** clearly labelled structure members 192 | ** 193 | ** Revision 1.2 2000/07/05 22:50:33 matt 194 | ** fixed punchout -- works 100% now 195 | ** 196 | ** Revision 1.1 2000/07/05 05:05:18 matt 197 | ** initial revision 198 | ** 199 | */ 200 | -------------------------------------------------------------------------------- /components/nofrendo/mappers/map042.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 | ** map042.c 21 | ** 22 | ** Mapper #42 (Baby Mario bootleg) 23 | ** Implementation by Firebug 24 | ** Mapper information courtesy of Kevin Horton 25 | ** $Id: map042.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 struct 36 | { 37 | bool enabled; 38 | uint32 counter; 39 | } irq; 40 | 41 | /********************************/ 42 | /* Mapper #42 IRQ reset routine */ 43 | /********************************/ 44 | static void map42_irq_reset (void) 45 | { 46 | /* Turn off IRQs */ 47 | irq.enabled = false; 48 | irq.counter = 0x0000; 49 | 50 | /* Done */ 51 | return; 52 | } 53 | 54 | /********************************************/ 55 | /* Mapper #42: Baby Mario bootleg cartridge */ 56 | /********************************************/ 57 | static void map42_init (void) 58 | { 59 | /* Set the hardwired pages */ 60 | mmc_bankrom (8, 0x8000, 0x0C); 61 | mmc_bankrom (8, 0xA000, 0x0D); 62 | mmc_bankrom (8, 0xC000, 0x0E); 63 | mmc_bankrom (8, 0xE000, 0x0F); 64 | 65 | /* Reset the IRQ counter */ 66 | map42_irq_reset (); 67 | 68 | /* Done */ 69 | return; 70 | } 71 | 72 | /****************************************/ 73 | /* Mapper #42 callback for IRQ handling */ 74 | /****************************************/ 75 | static void map42_hblank (int vblank) 76 | { 77 | /* Counter is M2 based so it doesn't matter whether */ 78 | /* the PPU is in its VBlank period or not */ 79 | UNUSED(vblank); 80 | 81 | /* Increment the counter if it is enabled and check for strike */ 82 | if (irq.enabled) 83 | { 84 | /* Is there a constant for cycles per scanline? */ 85 | /* If so, someone ought to substitute it here */ 86 | irq.counter = irq.counter + 114; 87 | 88 | /* IRQ is triggered after 24576 M2 cycles */ 89 | if (irq.counter >= 0x6000) 90 | { 91 | /* Trigger the IRQ */ 92 | nes_irq (); 93 | 94 | /* Reset the counter */ 95 | map42_irq_reset (); 96 | } 97 | } 98 | } 99 | 100 | /******************************************/ 101 | /* Mapper #42 write handler ($E000-$FFFF) */ 102 | /******************************************/ 103 | static void map42_write (uint32 address, uint8 value) 104 | { 105 | switch (address & 0x03) 106 | { 107 | /* Register 0: Select ROM page at $6000-$7FFF */ 108 | case 0x00: mmc_bankrom (8, 0x6000, value & 0x0F); 109 | break; 110 | 111 | /* Register 1: mirroring */ 112 | case 0x01: if (value & 0x08) ppu_mirror(0, 0, 1, 1); /* horizontal */ 113 | else ppu_mirror(0, 1, 0, 1); /* vertical */ 114 | break; 115 | 116 | /* Register 2: IRQ */ 117 | case 0x02: if (value & 0x02) irq.enabled = true; 118 | else map42_irq_reset (); 119 | break; 120 | 121 | /* Register 3: unused */ 122 | default: break; 123 | } 124 | 125 | /* Done */ 126 | return; 127 | } 128 | 129 | /****************************************************/ 130 | /* Shove extra mapper information into a SNSS block */ 131 | /****************************************************/ 132 | static void map42_setstate (SnssMapperBlock *state) 133 | { 134 | /* TODO: Store SNSS information */ 135 | UNUSED (state); 136 | 137 | /* Done */ 138 | return; 139 | } 140 | 141 | /*****************************************************/ 142 | /* Pull extra mapper information out of a SNSS block */ 143 | /*****************************************************/ 144 | static void map42_getstate (SnssMapperBlock *state) 145 | { 146 | /* TODO: Retrieve SNSS information */ 147 | UNUSED (state); 148 | 149 | /* Done */ 150 | return; 151 | } 152 | 153 | static map_memwrite map42_memwrite [] = 154 | { 155 | { 0xE000, 0xFFFF, map42_write }, 156 | { -1, -1, NULL } 157 | }; 158 | 159 | mapintf_t map42_intf = 160 | { 161 | 42, /* Mapper number */ 162 | "Baby Mario (bootleg)", /* Mapper name */ 163 | map42_init, /* Initialization routine */ 164 | NULL, /* VBlank callback */ 165 | map42_hblank, /* HBlank callback */ 166 | map42_getstate, /* Get state (SNSS) */ 167 | map42_setstate, /* Set state (SNSS) */ 168 | NULL, /* Memory read structure */ 169 | map42_memwrite, /* Memory write structure */ 170 | NULL /* External sound device */ 171 | }; 172 | 173 | /* 174 | ** $Log: map042.c,v $ 175 | ** Revision 1.2 2001/04/27 14:37:11 neil 176 | ** wheeee 177 | ** 178 | ** Revision 1.1 2001/04/27 12:54:40 neil 179 | ** blah 180 | ** 181 | ** Revision 1.1 2001/04/27 10:57:41 neil 182 | ** wheee 183 | ** 184 | ** Revision 1.1 2000/12/27 19:23:30 firebug 185 | ** initial revision 186 | ** 187 | ** 188 | */ 189 | --------------------------------------------------------------------------------