├── System_PSP ├── emulate.h ├── emumenu.h ├── system_rom.h ├── main.c ├── unzip │ ├── ioapi.h │ ├── ioapi.c │ └── crypt.h ├── neopop.c └── emulate.c ├── README.md ├── .gitattributes ├── .gitignore ├── Core ├── docs │ ├── todo.txt │ ├── source-readme.txt │ └── changelog.txt ├── bios.h ├── dma.h ├── flash.h ├── TLCS-900h │ ├── TLCS900h_registers_mapCodeL0.h │ ├── TLCS900h_registers_mapCodeL1.h │ ├── TLCS900h_registers_mapCodeL2.h │ ├── TLCS900h_registers_mapCodeL3.h │ ├── TLCS900h_registers_mapL.h │ ├── TLCS900h_registers_mapW.h │ ├── TLCS900h_disassemble.h │ ├── TLCS900h_registers_mapB.h │ ├── TLCS900h_interpret_dst.h │ ├── TLCS900h_interpret_single.h │ ├── TLCS900h_registers.h │ ├── TLCS900h_interpret_src.h │ ├── TLCS900h_registers_mapCodeW0.h │ ├── TLCS900h_interpret.h │ ├── TLCS900h_registers.c │ ├── TLCS900h_registers_mapCodeW1.h │ ├── TLCS900h_registers_mapCodeW2.h │ ├── TLCS900h_registers_mapCodeW3.h │ ├── TLCS900h_interpret_reg.h │ ├── TLCS900h_registers_mapCodeB0.h │ ├── TLCS900h_registers_mapCodeB1.h │ ├── TLCS900h_registers_mapCodeB2.h │ ├── TLCS900h_registers_mapCodeB3.h │ ├── TLCS900h_disassemble_dst.c │ ├── TLCS900h_interpret_dst.c │ ├── TLCS900h_disassemble_extra.c │ └── TLCS900h_interpret_single.c ├── Z80_interface.h ├── sound.h ├── mem.h ├── gfx.h ├── interrupt.h ├── gfx.c ├── z80 │ └── CodesXCB.h ├── state.h ├── Z80_interface.c ├── state.c └── neopop.c ├── Makefile.psp └── Makefile /System_PSP/emulate.h: -------------------------------------------------------------------------------- 1 | #ifndef _EMULATE_H 2 | #define _EMULATE_H 3 | 4 | void system_graphics_update(); 5 | 6 | int InitEmulation(); 7 | void RunEmulation(); 8 | void TrashEmulation(); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NeopopVITA 2 | 3 | Neogeo Pocket Color emulator for PSVita 4 | 5 | ## Requirements 6 | 7 | * PSPLIB for PSVita - https://github.com/frangarcj/psplib4vita 8 | 9 | ## Credits 10 | 11 | * 2007 Akop Karapetyan (port) 12 | * 2002 neopop_uk (emulation) 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | 45 | *.o 46 | RACE.elf 47 | *.elf 48 | *.velf 49 | background.png 50 | uvl.h 51 | db.json 52 | libUVL_stub.a 53 | -------------------------------------------------------------------------------- /Core/docs/todo.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------ 2 | Core\docs\todo.txt 3 | ------------------------------------------------------ 4 | Features to add to the emulation core 5 | ------------------------------------------------------ 6 | 7 | 8 | Far Future, or Never 9 | ==================== 10 | * Perfect the interrupt timings! - remove 'gfx_hack', big speedup! 11 | * Match Z80 clock speed to 1/2 TLCS-900h. 12 | * Count DMA wait state cycles. 13 | * Fix DAC? so the T1 rate hack on Timer 2 isn't required. 14 | timing issues are quite complex - see "Super Real Mahjong" 15 | * Timers not complete (obscure modes, used?) 16 | * Clock gear (used?), (remember that it affects timers). 17 | * Character over emulation (obscure, used?) 18 | * Optimise register access - precalculate pointers to rCodeB, rCodeW, rCodeL 19 | * Save flash data with save state - for better consistancy 20 | * FLASH erase (needed? what does the block number mean?) 21 | * Correct cycle counts for HLE bios functions (Difficult) 22 | * Support for real bios emulation 23 | * System Power Off (set bit 7 of 0x6F85) - useful? 24 | * System Resume (possible to suspend) 25 | 26 | -------------------------------------------------------------------------------- /System_PSP/emumenu.h: -------------------------------------------------------------------------------- 1 | /* NeoPop - Menu definitions */ 2 | 3 | #ifndef _EMUMENU_H 4 | #define _EMUMENU_H 5 | 6 | int InitMenu(); 7 | void DisplayMenu(); 8 | void TrashMenu(); 9 | 10 | #define DISPLAY_MODE_UNSCALED 0 11 | #define DISPLAY_MODE_FIT_HEIGHT 1 12 | #define DISPLAY_MODE_FILL_SCREEN 2 13 | #define DISPLAY_MODE_2X 3 14 | #define DISPLAY_MODE_3X 4 15 | #define DISPLAY_MODE_3X_BG 5 16 | 17 | #define JOY 0x100 18 | #define SPC 0x200 19 | 20 | #define CODE_MASK(x) (x & 0xff) 21 | 22 | #define SPC_MENU 1 23 | 24 | #define MAP_BUTTONS 18 25 | 26 | #define MAP_ANALOG_UP 0 27 | #define MAP_ANALOG_DOWN 1 28 | #define MAP_ANALOG_LEFT 2 29 | #define MAP_ANALOG_RIGHT 3 30 | #define MAP_BUTTON_UP 4 31 | #define MAP_BUTTON_DOWN 5 32 | #define MAP_BUTTON_LEFT 6 33 | #define MAP_BUTTON_RIGHT 7 34 | #define MAP_BUTTON_SQUARE 8 35 | #define MAP_BUTTON_CROSS 9 36 | #define MAP_BUTTON_CIRCLE 10 37 | #define MAP_BUTTON_TRIANGLE 11 38 | #define MAP_BUTTON_LTRIGGER 12 39 | #define MAP_BUTTON_RTRIGGER 13 40 | #define MAP_BUTTON_SELECT 14 41 | #define MAP_BUTTON_START 15 42 | #define MAP_BUTTON_LRTRIGGERS 16 43 | #define MAP_BUTTON_STARTSELECT 17 44 | 45 | typedef struct 46 | { 47 | int ShowFps; 48 | int ControlMode; 49 | int ClockFreq; 50 | int DisplayMode; 51 | int VSync; 52 | int UpdateFreq; 53 | int Frameskip; 54 | } EmulatorOptions; 55 | 56 | struct ButtonConfig 57 | { 58 | unsigned int ButtonMap[MAP_BUTTONS]; 59 | }; 60 | 61 | #endif // _EMUMENU_H 62 | -------------------------------------------------------------------------------- /System_PSP/system_rom.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | system_rom.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 21 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Created this file to remove some of the mess from 'system_main.c' and 30 | to make rom loading more abstracted, primarily for ports to systems with 31 | alternate methods of loading roms. 32 | 33 | //--------------------------------------------------------------------------- 34 | */ 35 | 36 | #ifndef __SYSTEM_ROM__ 37 | #define __SYSTEM_ROM__ 38 | //============================================================================= 39 | 40 | BOOL system_load_rom(char* filename); 41 | void system_unload_rom(void); 42 | 43 | //============================================================================= 44 | #endif 45 | -------------------------------------------------------------------------------- /System_PSP/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "psplib/pl_snd.h" 8 | #include "psplib/video.h" 9 | #include "psplib/pl_psp.h" 10 | #include "psplib/ctrl.h" 11 | #include 12 | 13 | #include "emumenu.h" 14 | #include "revitalize.h" 15 | 16 | char *stpcpy(char *dest, const char *src) 17 | { 18 | register char *d = dest; 19 | register const char *s = src; 20 | 21 | do { 22 | *d++ = *s; 23 | } while (*s++ != '\0'); 24 | 25 | return d - 1; 26 | } 27 | 28 | PSP2_MODULE_INFO(0,1,PSP_APP_NAME); 29 | //PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER); 30 | 31 | void show_splash() 32 | { 33 | vita2d_start_drawing(); 34 | vita2d_clear_screen(); 35 | 36 | vita2d_texture *splash = vita2d_create_empty_texture(960, 544); 37 | 38 | splash = vita2d_load_PNG_buffer(revitalize); 39 | 40 | vita2d_draw_texture(splash, 0, 0); 41 | 42 | vita2d_end_drawing(); 43 | vita2d_swap_buffers(); 44 | 45 | sceKernelDelayThread(5000000); // Delay 5 seconds 46 | 47 | vita2d_free_texture(splash); 48 | } 49 | 50 | static void ExitCallback(void* arg) 51 | { 52 | ExitPSP = 1; 53 | } 54 | int main(int argc, char **argv) 55 | { 56 | /* Initialize PSP */ 57 | pl_psp_init("ux0:/data/NeopopVITA/"); 58 | pl_snd_init(512,1); 59 | pspCtrlInit(); 60 | pspVideoInit(); 61 | 62 | // show_splash(); 63 | #ifdef PSP_DEBUG 64 | FILE *debug = fopen("message.txt", "w"); 65 | fclose(debug); 66 | #endif 67 | 68 | /* Initialize callbacks */ 69 | pl_psp_register_callback(PSP_EXIT_CALLBACK, ExitCallback, NULL); 70 | pl_psp_start_callback_thread(); 71 | 72 | /* Show the menu */ 73 | if (InitMenu()) 74 | { 75 | DisplayMenu(); 76 | TrashMenu(); 77 | } 78 | 79 | /* Release PSP resources */ 80 | pl_snd_shutdown(); 81 | pspVideoShutdown(); 82 | pl_psp_shutdown(); 83 | 84 | return(0); 85 | } 86 | -------------------------------------------------------------------------------- /Core/bios.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | bios.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 18 AUG 2002 - neopop_uk 32 | ======================================= 33 | - Moved reset() and biosInstall() to neopop.h 34 | 35 | //--------------------------------------------------------------------------- 36 | */ 37 | 38 | #ifndef __BIOS__ 39 | #define __BIOS__ 40 | //============================================================================= 41 | 42 | extern _u8 bios[0x10000]; 43 | 44 | void iBIOSHLE(void); 45 | 46 | void update_rtc(void); 47 | 48 | void biosDecode(int function); 49 | 50 | //============================================================================= 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /Core/dma.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | dma.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 25 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added function prototype for DMA_update 34 | 35 | //--------------------------------------------------------------------------- 36 | */ 37 | 38 | #ifndef __DMA__ 39 | #define __DMA__ 40 | //============================================================================= 41 | 42 | void reset_dma(void); 43 | 44 | void DMA_update(int channel); 45 | 46 | extern _u32 dmaS[4], dmaD[4]; 47 | extern _u16 dmaC[4]; 48 | extern _u8 dmaM[4]; 49 | 50 | _u8 dmaLoadB(_u8 cr); 51 | _u16 dmaLoadW(_u8 cr); 52 | _u32 dmaLoadL(_u8 cr); 53 | 54 | void dmaStoreB(_u8 cr, _u8 data); 55 | void dmaStoreW(_u8 cr, _u16 data); 56 | void dmaStoreL(_u8 cr, _u32 data); 57 | 58 | //============================================================================= 59 | #endif 60 | -------------------------------------------------------------------------------- /Core/flash.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | flash.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 26 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Removed the eeprom emulation functions and data. 34 | - Renamed this file "flash.h" 35 | 36 | 10 AUG 2002 - neopop_uk 37 | ======================================= 38 | - Added flash_commit function to do the writing. 39 | 40 | //--------------------------------------------------------------------------- 41 | */ 42 | 43 | #ifndef __FLASH__ 44 | #define __FLASH__ 45 | //============================================================================= 46 | 47 | void flash_read(void); 48 | 49 | //Marks flash blocks for saving. 50 | void flash_write(_u32 start_address, _u16 length); 51 | 52 | //Stores the flash data 53 | void flash_commit(void); 54 | 55 | //============================================================================= 56 | #endif 57 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeL0.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeL0.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | &(gprBank[0][0]), &(gprBank[0][1]), &(gprBank[0][2]), &(gprBank[0][3]), 36 | 37 | //BANK 1 38 | &(gprBank[1][0]), &(gprBank[1][1]), &(gprBank[1][2]), &(gprBank[1][3]), 39 | 40 | //BANK 2 41 | &(gprBank[2][0]), &(gprBank[2][1]), &(gprBank[2][2]), &(gprBank[2][3]), 42 | 43 | //BANK 3 44 | &(gprBank[3][0]), &(gprBank[3][1]), &(gprBank[3][2]), &(gprBank[3][3]), 45 | 46 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 47 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 48 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 49 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 50 | &rErr,&rErr,&rErr,&rErr, 51 | 52 | //Previous Bank 53 | &rErr,&rErr,&rErr,&rErr, 54 | 55 | //Current Bank 56 | &(gprBank[0][0]), &(gprBank[0][1]), &(gprBank[0][2]), &(gprBank[0][3]), 57 | 58 | &(gpr[0]), &(gpr[1]), &(gpr[2]), &(gpr[3]) 59 | 60 | //============================================================================= 61 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeL1.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeL1.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | &(gprBank[0][0]), &(gprBank[0][1]), &(gprBank[0][2]), &(gprBank[0][3]), 36 | 37 | //BANK 1 38 | &(gprBank[1][0]), &(gprBank[1][1]), &(gprBank[1][2]), &(gprBank[1][3]), 39 | 40 | //BANK 2 41 | &(gprBank[2][0]), &(gprBank[2][1]), &(gprBank[2][2]), &(gprBank[2][3]), 42 | 43 | //BANK 3 44 | &(gprBank[3][0]), &(gprBank[3][1]), &(gprBank[3][2]), &(gprBank[3][3]), 45 | 46 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 47 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 48 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 49 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 50 | &rErr,&rErr,&rErr,&rErr, 51 | 52 | //Previous Bank 53 | &(gprBank[0][0]), &(gprBank[0][1]), &(gprBank[0][2]), &(gprBank[0][3]), 54 | 55 | //Current Bank 56 | &(gprBank[1][0]), &(gprBank[1][1]), &(gprBank[1][2]), &(gprBank[1][3]), 57 | 58 | &(gpr[0]), &(gpr[1]), &(gpr[2]), &(gpr[3]) 59 | 60 | //============================================================================= 61 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeL2.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeL2.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | &(gprBank[0][0]), &(gprBank[0][1]), &(gprBank[0][2]), &(gprBank[0][3]), 36 | 37 | //BANK 1 38 | &(gprBank[1][0]), &(gprBank[1][1]), &(gprBank[1][2]), &(gprBank[1][3]), 39 | 40 | //BANK 2 41 | &(gprBank[2][0]), &(gprBank[2][1]), &(gprBank[2][2]), &(gprBank[2][3]), 42 | 43 | //BANK 3 44 | &(gprBank[3][0]), &(gprBank[3][1]), &(gprBank[3][2]), &(gprBank[3][3]), 45 | 46 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 47 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 48 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 49 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 50 | &rErr,&rErr,&rErr,&rErr, 51 | 52 | //Previous Bank 53 | &(gprBank[1][0]), &(gprBank[1][1]), &(gprBank[1][2]), &(gprBank[1][3]), 54 | 55 | //Current Bank 56 | &(gprBank[2][0]), &(gprBank[2][1]), &(gprBank[2][2]), &(gprBank[2][3]), 57 | 58 | &(gpr[0]), &(gpr[1]), &(gpr[2]), &(gpr[3]) 59 | 60 | //============================================================================= 61 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeL3.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeL3.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | &(gprBank[0][0]), &(gprBank[0][1]), &(gprBank[0][2]), &(gprBank[0][3]), 36 | 37 | //BANK 1 38 | &(gprBank[1][0]), &(gprBank[1][1]), &(gprBank[1][2]), &(gprBank[1][3]), 39 | 40 | //BANK 2 41 | &(gprBank[2][0]), &(gprBank[2][1]), &(gprBank[2][2]), &(gprBank[2][3]), 42 | 43 | //BANK 3 44 | &(gprBank[3][0]), &(gprBank[3][1]), &(gprBank[3][2]), &(gprBank[3][3]), 45 | 46 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 47 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 48 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 49 | &rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr,&rErr, 50 | &rErr,&rErr,&rErr,&rErr, 51 | 52 | //Previous Bank 53 | &(gprBank[2][0]), &(gprBank[2][1]), &(gprBank[2][2]), &(gprBank[2][3]), 54 | 55 | //Current Bank 56 | &(gprBank[3][0]), &(gprBank[3][1]), &(gprBank[3][2]), &(gprBank[3][3]), 57 | 58 | &(gpr[0]), &(gpr[1]), &(gpr[2]), &(gpr[3]) 59 | 60 | //============================================================================= 61 | -------------------------------------------------------------------------------- /Core/Z80_interface.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | Z80_interface.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef __Z80_CONTROL__ 35 | #define __Z80_CONTROL__ 36 | //============================================================================= 37 | 38 | #include "Z80.h" 39 | 40 | void Z80_reset(void); // z80 reset 41 | 42 | void Z80_irq(void); // Cause an interrupt 43 | void Z80_nmi(void); // Cause an NMI 44 | 45 | #define Z80ACTIVE (ram[0xb9] == 0x55) 46 | 47 | //Emulate a z80 instruction 48 | #define Z80EMULATE { ExecZ80(&Z80_regs); } 49 | 50 | //Register status 51 | #define Z80_REG_AF 0 52 | #define Z80_REG_BC 1 53 | #define Z80_REG_DE 2 54 | #define Z80_REG_HL 3 55 | #define Z80_REG_IX 4 56 | #define Z80_REG_IY 5 57 | #define Z80_REG_PC 6 58 | #define Z80_REG_SP 7 59 | #define Z80_REG_AF1 8 60 | #define Z80_REG_BC1 9 61 | #define Z80_REG_DE1 10 62 | #define Z80_REG_HL1 11 63 | 64 | _u16 Z80_getReg(_u8 reg); 65 | void Z80_setReg(_u8 reg, _u16 value); 66 | 67 | //Disassembles a single instruction from 'pc', 68 | char* Z80_disassemble(_u16* pc); 69 | 70 | extern Z80 Z80_regs; 71 | 72 | //============================================================================= 73 | #endif 74 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapL.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapL.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //Bank 0 35 | { 36 | (_u32*)&(gprBank[0][0]), 37 | (_u32*)&(gprBank[0][1]), 38 | (_u32*)&(gprBank[0][2]), 39 | (_u32*)&(gprBank[0][3]), 40 | (_u32*)&(gpr[0]), 41 | (_u32*)&(gpr[1]), 42 | (_u32*)&(gpr[2]), 43 | (_u32*)&(gpr[3]), 44 | }, 45 | 46 | //Bank 1 47 | { 48 | (_u32*)&(gprBank[1][0]), 49 | (_u32*)&(gprBank[1][1]), 50 | (_u32*)&(gprBank[1][2]), 51 | (_u32*)&(gprBank[1][3]), 52 | (_u32*)&(gpr[0]), 53 | (_u32*)&(gpr[1]), 54 | (_u32*)&(gpr[2]), 55 | (_u32*)&(gpr[3]), 56 | }, 57 | 58 | //Bank 2 59 | { 60 | (_u32*)&(gprBank[2][0]), 61 | (_u32*)&(gprBank[2][1]), 62 | (_u32*)&(gprBank[2][2]), 63 | (_u32*)&(gprBank[2][3]), 64 | (_u32*)&(gpr[0]), 65 | (_u32*)&(gpr[1]), 66 | (_u32*)&(gpr[2]), 67 | (_u32*)&(gpr[3]), 68 | }, 69 | 70 | //Bank 3 71 | { 72 | (_u32*)&(gprBank[3][0]), 73 | (_u32*)&(gprBank[3][1]), 74 | (_u32*)&(gprBank[3][2]), 75 | (_u32*)&(gprBank[3][3]), 76 | (_u32*)&(gpr[0]), 77 | (_u32*)&(gpr[1]), 78 | (_u32*)&(gpr[2]), 79 | (_u32*)&(gpr[3]), 80 | }, 81 | 82 | //============================================================================= 83 | 84 | 85 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapW.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapW.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //Bank 0 35 | { 36 | (_u16*)&(gprBank[0][0]), 37 | (_u16*)&(gprBank[0][1]), 38 | (_u16*)&(gprBank[0][2]), 39 | (_u16*)&(gprBank[0][3]), 40 | (_u16*)&(gpr[0]), 41 | (_u16*)&(gpr[1]), 42 | (_u16*)&(gpr[2]), 43 | (_u16*)&(gpr[3]), 44 | }, 45 | 46 | //Bank 1 47 | { 48 | (_u16*)&(gprBank[1][0]), 49 | (_u16*)&(gprBank[1][1]), 50 | (_u16*)&(gprBank[1][2]), 51 | (_u16*)&(gprBank[1][3]), 52 | (_u16*)&(gpr[0]), 53 | (_u16*)&(gpr[1]), 54 | (_u16*)&(gpr[2]), 55 | (_u16*)&(gpr[3]), 56 | }, 57 | 58 | //Bank 2 59 | { 60 | (_u16*)&(gprBank[2][0]), 61 | (_u16*)&(gprBank[2][1]), 62 | (_u16*)&(gprBank[2][2]), 63 | (_u16*)&(gprBank[2][3]), 64 | (_u16*)&(gpr[0]), 65 | (_u16*)&(gpr[1]), 66 | (_u16*)&(gpr[2]), 67 | (_u16*)&(gpr[3]), 68 | }, 69 | 70 | //Bank 3 71 | { 72 | (_u16*)&(gprBank[3][0]), 73 | (_u16*)&(gprBank[3][1]), 74 | (_u16*)&(gprBank[3][2]), 75 | (_u16*)&(gprBank[3][3]), 76 | (_u16*)&(gpr[0]), 77 | (_u16*)&(gpr[1]), 78 | (_u16*)&(gpr[2]), 79 | (_u16*)&(gpr[3]), 80 | }, 81 | 82 | //============================================================================= 83 | 84 | 85 | -------------------------------------------------------------------------------- /Makefile.psp: -------------------------------------------------------------------------------- 1 | PSPSDK=$(shell psp-config --pspsdk-path) 2 | 3 | PSPAPP=System_PSP 4 | DATA=$(PSPAPP)/data 5 | PSPLIB=$(PSPAPP)/psplib 6 | ZLIB=$(PSPAPP)/zLIB 7 | 8 | CORE=Core 9 | TLCS900=$(CORE)/TLCS-900h 10 | Z80=$(CORE)/z80 11 | 12 | PSP_APP_NAME=NeoPop PSP 13 | PSP_APP_VER=0.71.15 14 | 15 | TARGET=neopoppsp 16 | EXTRA_TARGETS=EBOOT.PBP 17 | PSP_EBOOT_TITLE=$(PSP_APP_NAME) $(PSP_APP_VER) 18 | PSP_EBOOT_ICON=$(DATA)/neopop-icon.png 19 | 20 | BUILD_APP=$(Z80)/Z80.o $(Z80)/dasm.o $(CORE)/Z80_interface.o \ 21 | $(TLCS900)/TLCS900h_registers.o \ 22 | $(TLCS900)/TLCS900h_interpret_src.o \ 23 | $(TLCS900)/TLCS900h_interpret_single.o \ 24 | $(TLCS900)/TLCS900h_interpret_reg.o \ 25 | $(TLCS900)/TLCS900h_interpret_dst.o \ 26 | $(TLCS900)/TLCS900h_interpret.o \ 27 | $(TLCS900)/TLCS900h_disassemble_src.o \ 28 | $(TLCS900)/TLCS900h_disassemble_reg.o \ 29 | $(TLCS900)/TLCS900h_disassemble_extra.o \ 30 | $(TLCS900)/TLCS900h_disassemble_dst.o \ 31 | $(TLCS900)/TLCS900h_disassemble.o \ 32 | $(CORE)/dma.o $(CORE)/bios.o $(CORE)/biosHLE.o $(CORE)/mem.o \ 33 | $(CORE)/interrupt.o $(CORE)/gfx.o $(CORE)/sound.o \ 34 | $(CORE)/gfx_scanline_colour.o $(CORE)/gfx_scanline_mono.o \ 35 | $(CORE)/flash.o $(CORE)/rom.o $(CORE)/state.o $(CORE)/neopop.o \ 36 | $(ZLIB)/crc32.o $(ZLIB)/adler32.o $(ZLIB)/unzip.o $(ZLIB)/zutil.o \ 37 | $(ZLIB)/infblock.o $(ZLIB)/inffast.o $(ZLIB)/infutil.o \ 38 | $(ZLIB)/infcodes.o $(ZLIB)/inflate.o $(ZLIB)/inftrees.o 39 | BUILD_PSPLIB=$(PSPLIB)/psp.o $(PSPLIB)/font.o $(PSPLIB)/image.o \ 40 | $(PSPLIB)/video.o $(PSPLIB)/audio.o $(PSPLIB)/fileio.o \ 41 | $(PSPLIB)/menu.o $(PSPLIB)/ui.o $(PSPLIB)/ctrl.o \ 42 | $(PSPLIB)/kybd.o $(PSPLIB)/perf.o $(PSPLIB)/util.o \ 43 | $(PSPLIB)/init.o 44 | BUILD_PSPAPP=$(PSPAPP)/emulate.o $(PSPAPP)/emumenu.o $(PSPAPP)/neopop.o \ 45 | $(PSPAPP)/system_rom.o $(PSPAPP)/main.o 46 | 47 | OBJS=$(BUILD_APP) $(BUILD_PSPLIB) $(BUILD_PSPAPP) 48 | 49 | DEFINES=-DCHIP_FREQUENCY=22050 #-DPSP_DEBUG 50 | BASE_DEFS=-DPSP \ 51 | -DPSP_APP_VER=\"$(PSP_APP_VER)\" \ 52 | -DPSP_APP_NAME="\"$(PSP_APP_NAME)\"" 53 | CFLAGS=-O2 -G0 -Wall $(BASE_DEFS) $(DEFINES) 54 | CXXFLAGS=$(CFLAGS) -fno-exceptions -fno-rtti 55 | ASFLAGS=$(CFLAGS) 56 | INCDIR=$(PSPLIB) $(PSPAPP) $(CORE) $(TLCS900) $(Z80) $(ZLIB) 57 | LIBS=-lpng -lz -lm -lc -lpspgu -lpsppower -lpspaudio -lpsprtc 58 | 59 | include $(PSPSDK)/lib/build.mak 60 | 61 | include $(PSPLIB)/build.mak 62 | 63 | -------------------------------------------------------------------------------- /Core/sound.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | sound.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 03 AUG 2002 - neopop_uk 32 | ======================================= 33 | - Added dac_update function 34 | - Made the DAC buffer frequency a global define. 35 | - Converted DAC to mono, it never gets used in stereo. 36 | 37 | //--------------------------------------------------------------------------- 38 | */ 39 | 40 | #ifndef __SOUND__ 41 | #define __SOUND__ 42 | //============================================================================= 43 | 44 | typedef struct 45 | { 46 | int LastRegister; /* last register written */ 47 | int Register[8]; /* registers */ 48 | int Volume[4]; 49 | int Period[4]; 50 | int Count[4]; 51 | int Output[4]; 52 | 53 | unsigned int RNG; /* noise generator */ 54 | int NoiseFB; /* noise feedback mask */ 55 | 56 | } SoundChip; 57 | 58 | //============================================================================= 59 | 60 | extern SoundChip toneChip; 61 | extern SoundChip noiseChip; 62 | 63 | void WriteSoundChip(SoundChip* chip, _u8 data); 64 | 65 | #define Write_SoundChipTone(VALUE) (WriteSoundChip(&toneChip, VALUE)) 66 | #define Write_SoundChipNoise(VALUE) (WriteSoundChip(&noiseChip, VALUE)) 67 | 68 | //============================================================================= 69 | 70 | void dac_write(void); 71 | 72 | //============================================================================= 73 | #endif 74 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_disassemble.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_disassemble.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef __TLCS900H_DISASSEMBLE__ 35 | #define __TLCS900H_DISASSEMBLE__ 36 | //============================================================================= 37 | 38 | //Disassembles a single instruction from 'pc', 39 | //pc is incremented to the start of the next instruction. 40 | char* TLCS900h_disassemble(void); 41 | 42 | //Print to this string the disassembled instruction 43 | extern char instr[128]; 44 | 45 | //Print the mnemonic for the addressing mode / reg code. 46 | extern char extra[32]; 47 | 48 | //============================================================================= 49 | 50 | extern char str_R[8]; //Big R 51 | extern char str_r[8]; //Little R 52 | 53 | //Translate an rr or RR value for MUL/MULS/DIV/DIVS 54 | void get_rr_Name(void); 55 | void get_RR_Name(void); 56 | 57 | extern _u8 bytes[16]; //Stores the bytes used 58 | extern _u8 bcnt; //Byte Counter for above 59 | 60 | extern char* gprName[8][3]; //8 regs * 3 names (byte, word, long) 61 | extern char* regCodeName[3][256]; 62 | extern char* crName[3][0x40]; 63 | 64 | extern char* ccName[]; 65 | 66 | _u8 get8_dis(void); 67 | _u16 get16_dis(void); 68 | _u32 get24_dis(void); 69 | _u32 get32_dis(void); 70 | 71 | //============================================================================= 72 | #endif 73 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapB.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapB.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //Bank 0 35 | { 36 | (_u8*)&(gprBank[0][0]) + 1, 37 | (_u8*)&(gprBank[0][0]) + 0, 38 | (_u8*)&(gprBank[0][1]) + 1, 39 | (_u8*)&(gprBank[0][1]) + 0, 40 | (_u8*)&(gprBank[0][2]) + 1, 41 | (_u8*)&(gprBank[0][2]) + 0, 42 | (_u8*)&(gprBank[0][3]) + 1, 43 | (_u8*)&(gprBank[0][3]) + 0, 44 | }, 45 | 46 | //Bank 1 47 | { 48 | (_u8*)&(gprBank[1][0]) + 1, 49 | (_u8*)&(gprBank[1][0]) + 0, 50 | (_u8*)&(gprBank[1][1]) + 1, 51 | (_u8*)&(gprBank[1][1]) + 0, 52 | (_u8*)&(gprBank[1][2]) + 1, 53 | (_u8*)&(gprBank[1][2]) + 0, 54 | (_u8*)&(gprBank[1][3]) + 1, 55 | (_u8*)&(gprBank[1][3]) + 0, 56 | }, 57 | 58 | //Bank 2 59 | { 60 | (_u8*)&(gprBank[2][0]) + 1, 61 | (_u8*)&(gprBank[2][0]) + 0, 62 | (_u8*)&(gprBank[2][1]) + 1, 63 | (_u8*)&(gprBank[2][1]) + 0, 64 | (_u8*)&(gprBank[2][2]) + 1, 65 | (_u8*)&(gprBank[2][2]) + 0, 66 | (_u8*)&(gprBank[2][3]) + 1, 67 | (_u8*)&(gprBank[2][3]) + 0, 68 | }, 69 | 70 | //Bank 3 71 | { 72 | (_u8*)&(gprBank[3][0]) + 1, 73 | (_u8*)&(gprBank[3][0]) + 0, 74 | (_u8*)&(gprBank[3][1]) + 1, 75 | (_u8*)&(gprBank[3][1]) + 0, 76 | (_u8*)&(gprBank[3][2]) + 1, 77 | (_u8*)&(gprBank[3][2]) + 0, 78 | (_u8*)&(gprBank[3][3]) + 1, 79 | (_u8*)&(gprBank[3][3]) + 0, 80 | } 81 | 82 | //============================================================================= 83 | 84 | -------------------------------------------------------------------------------- /System_PSP/unzip/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.00, September 10th, 2003 5 | 6 | Copyright (C) 1998-2003 Gilles Vollant 7 | */ 8 | 9 | #ifndef _ZLIBIOAPI_H 10 | #define _ZLIBIOAPI_H 11 | 12 | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 14 | #define ZLIB_FILEFUNC_SEEK_END (2) 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) 16 | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 20 | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 23 | 24 | 25 | #ifndef ZCALLBACK 26 | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 28 | #define ZCALLBACK CALLBACK 29 | #else 30 | #define ZCALLBACK 31 | #endif 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 45 | 46 | typedef struct zlib_filefunc_def_s 47 | { 48 | open_file_func zopen_file; 49 | read_file_func zread_file; 50 | write_file_func zwrite_file; 51 | tell_file_func ztell_file; 52 | seek_file_func zseek_file; 53 | close_file_func zclose_file; 54 | testerror_file_func zerror_file; 55 | voidpf opaque; 56 | } zlib_filefunc_def; 57 | 58 | 59 | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 61 | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /Core/mem.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | mem.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 15 AUG 2002 - neopop_uk 32 | ======================================= 33 | - Removed the legacy 'eeprom' variables. 34 | 35 | 18 AUG 2002 - neopop_uk 36 | ======================================= 37 | - Moved RAM_START/RAM_END definition and ram[] declaration to NeoPop.h 38 | 39 | //--------------------------------------------------------------------------- 40 | */ 41 | 42 | #ifndef __MEM__ 43 | #define __MEM__ 44 | //============================================================================= 45 | 46 | #define ROM_START 0x200000 47 | #define ROM_END 0x3FFFFF 48 | 49 | #define HIROM_START 0x800000 50 | #define HIROM_END 0x9FFFFF 51 | 52 | #define BIOS_START 0xFF0000 53 | #define BIOS_END 0xFFFFFF 54 | 55 | void reset_memory(void); 56 | 57 | void* translate_address_read(_u32 address); 58 | void* translate_address_write(_u32 address); 59 | 60 | void dump_memory(_u32 start, _u32 length); 61 | 62 | extern BOOL debug_abort_memory; 63 | extern BOOL debug_mask_memory_error_messages; 64 | 65 | extern BOOL memory_unlock_flash_write; 66 | extern BOOL memory_flash_error; 67 | extern BOOL memory_flash_command; 68 | 69 | extern BOOL eepromStatusEnable; 70 | 71 | //============================================================================= 72 | 73 | _u8 loadB(_u32 address); 74 | _u16 loadW(_u32 address); 75 | _u32 loadL(_u32 address); 76 | _u32 load24(_u32 address); 77 | _u8 loadBRom(_u32 address); 78 | 79 | void storeB(_u32 address, _u8 data); 80 | void storeW(_u32 address, _u16 data); 81 | void storeL(_u32 address, _u32 data); 82 | void store24(_u32 address, _u32 data); 83 | 84 | //============================================================================= 85 | #endif 86 | -------------------------------------------------------------------------------- /Core/gfx.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | gfx.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 24 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added delayed setting of the Negative RGB output switch. 34 | 35 | 16 AUG 2002 - neopop_uk 36 | ======================================= 37 | - Removed data8, data16 and data32 38 | 39 | //--------------------------------------------------------------------------- 40 | */ 41 | 42 | #ifndef __GFX__ 43 | #define __GFX__ 44 | //============================================================================= 45 | 46 | #define ZDEPTH_BACK_SPRITE 2 47 | #define ZDEPTH_BACKGROUND_SCROLL 3 48 | #define ZDEPTH_MIDDLE_SPRITE 4 49 | #define ZDEPTH_FOREGROUND_SCROLL 5 50 | #define ZDEPTH_FRONT_SPRITE 6 51 | 52 | //============================================================================= 53 | 54 | //--------------------------- 55 | // Common Graphics Variables 56 | //--------------------------- 57 | 58 | extern _u8 zbuffer[256]; //Line z-buffer 59 | extern _u16* cfb_scanline; //set = cfb + (scanline * SCREEN_WIDTH) 60 | 61 | extern _u8 scanline; //Current scanline 62 | extern _u8 interlace; //which scanlines are drawn (even or odd) 63 | 64 | extern _u8 winx, winw; 65 | extern _u8 winy, winh; 66 | extern _u8 scroll1x, scroll1y; 67 | extern _u8 scroll2x, scroll2y; 68 | extern _u8 scrollsprx, scrollspry; 69 | extern _u8 planeSwap; 70 | extern _u8 bgc, oowc, negative; 71 | 72 | extern _u16 r,g,b; 73 | 74 | void gfx_delayed_settings(void); 75 | 76 | //============================================================================= 77 | 78 | void gfx_draw_scanline_colour(void); 79 | void gfx_draw_scanline_mono(void); 80 | 81 | //============================================================================= 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /Core/interrupt.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | interrupt.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 26 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Boiled the H/V problem down so that it hangs on one variable: gfx_hack. 34 | This isn't great, but it'll have to do for now... 35 | 36 | 01 AUG 2002 - neopop_uk 37 | ======================================= 38 | - Added support for frameskipping. 39 | 40 | 16 AUG 2002 - neopop_uk 41 | ======================================= 42 | - Added prototypes for split interrupt functions. 43 | 44 | 30 AUG 2002 - neopop_uk 45 | ======================================= 46 | - Removed frameskipping. 47 | 48 | 09 SEP 2002 - neopop_uk 49 | ======================================= 50 | - Unified timer update calls. 51 | - Corrected timer speeds. 52 | 53 | //--------------------------------------------------------------------------- 54 | */ 55 | 56 | #ifndef __INTERRUPT__ 57 | #define __INTERRUPT__ 58 | //============================================================================= 59 | 60 | void interrupt(_u8 index); 61 | 62 | #define TIMER_HINT_RATE 515 //CPU Ticks between horizontal interrupts 63 | 64 | #define TIMER_BASE_RATE 240 //ticks 65 | 66 | #define TIMER_T1_RATE (1 * TIMER_BASE_RATE) 67 | #define TIMER_T4_RATE (4 * TIMER_BASE_RATE) 68 | #define TIMER_T16_RATE (16 * TIMER_BASE_RATE) 69 | #define TIMER_T256_RATE (256 * TIMER_BASE_RATE) 70 | 71 | void reset_timers(void); 72 | 73 | //Call this after each instruction 74 | void updateTimers(_u8 cputicks); 75 | 76 | //H-INT Timer 77 | extern _u32 timer_hint; 78 | extern _u8 timer[4]; //Up-counters 79 | extern _u32 timer_clock0, timer_clock1, timer_clock2, timer_clock3; 80 | 81 | // Set this value to fix problems with glitching extra lines. 82 | extern BOOL gfx_hack; 83 | 84 | //============================================================================= 85 | #endif 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Core/docs/source-readme.txt: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------- 3 | source-readme.txt 4 | --------------------------------------------------------- 5 | 6 | This file is a simple attempt at explaining some subtleties of the 7 | NeoPop source code. It will eventually turn into a sort of FAQ. 8 | 9 | If you feel I have omitted something that isn't as obvious as I thought 10 | it was then let me know! It's difficult to see this project from the 11 | point of view of an outsider... 12 | 13 | 14 | 15 | 1. Additional Include paths 16 | ============================ 17 | 18 | In order to simplify the core layout and readability, I have chosen 19 | to define some additional include paths. These are (for all builds): 20 | 21 | Core\, 22 | Core\TLCS900h\, 23 | Core\Z80\ 24 | 25 | 26 | 27 | 2. The Debugger 28 | ================ 29 | 30 | A build including the debugger is activated by defining 'NEOPOP_DEBUG' 31 | globally. In the Windows port this is done using the project settings, 32 | but GCC can use the -D command line option (IIRC). 33 | 34 | I don't expect many people to bother porting the Windows debugger - 35 | it would require a complete re-write. I'm not sure this is to anyone's 36 | advantage because I don't believe there are many people that use it... 37 | I may be wrong. 38 | 39 | I have tried to make it as easy as possible to remove the debugger 40 | from the code base - simply remove the Debugger folder. 41 | The "#ifdef NEOPOP_DEBUG" directives will prevent any debugging code from 42 | being compiled. 43 | 44 | 45 | 46 | 3. ZIP Support 47 | =============== 48 | 49 | ZIP support (provided by zLIB 1.1.4) can optionally be omitted by changing 50 | a #define in 'system_rom.h' and removing the 'zLIB' folder. 51 | 52 | 53 | 54 | 4. Flash Support 55 | ================= 56 | 57 | Flash support can be omitted initially by just returning 'false' when reading 58 | and 'true' when writing - this will keep the core happy. I hope that porters 59 | can manage the unpredictably long flash files - only an issue for consoles, 60 | i'd say. I guess they could be padded out to a fixed 2 / 4 / 8 kb if need be. 61 | Or they could be zipped, this crushes the "Sonic" data from 6168 bytes to 309! 62 | 63 | 64 | 65 | 5. Porting and Core Consistency 66 | ================================ 67 | 68 | The source code for the O/S specific wrapper should be put into a folder 69 | called 'SYSTEM_xxx', where xxx is the name of the system. For example 70 | "SYSTEM_LINUX-SDL", "SYSTEM_DC", "SYSTEM_MACOS", etc... 71 | 72 | My aim is to have only one commmon core code for all ports. To facilitate this 73 | the predefined symbol 'SYSTEM_xxx' should be used to mark out any core componenets 74 | that only apply to a single system. Hopefully these can be kept to a minimum, 75 | but there may be cause for this approach on some systems. 76 | 77 | Makefiles should indicate the port system in their file extension. For example 78 | the DreamCast port would have a makefile called: "makefile.dc". 79 | 80 | THE CORE IS SUBJECT TO CHANGE AT ANY TIME! The only file to rely on 81 | is 'neopop.h', this is the only core file that should be included by a system 82 | file. If there is something missing from this file, please e-mail me. 83 | -------------------------------------------------------------------------------- /Core/gfx.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | gfx.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 24 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added Negative/Positive switch - used in "Faselei!" in B&W mode. 34 | 35 | 16 AUG 2002 - neopop_uk 36 | ======================================= 37 | - Removed data8, data16 and data32 38 | 39 | //--------------------------------------------------------------------------- 40 | */ 41 | 42 | #include "neopop.h" 43 | #include "mem.h" 44 | #include "gfx.h" 45 | 46 | //============================================================================= 47 | 48 | _u16* cfb;//[256*256]; 49 | _u8 zbuffer[256]; 50 | 51 | _u16* cfb_scanline; //set = scanline * SCREEN_WIDTH 52 | _u8 scanline; 53 | _u8 interlace; 54 | 55 | _u8 winx = 0, winw = SCREEN_WIDTH; 56 | _u8 winy = 0, winh = SCREEN_HEIGHT; 57 | _u8 scroll1x = 0, scroll1y = 0; 58 | _u8 scroll2x = 0, scroll2y = 0; 59 | _u8 scrollsprx = 0, scrollspry = 0; 60 | _u8 planeSwap = 0; 61 | _u8 bgc = 0, oowc = 0; 62 | 63 | _u16 r,g,b; 64 | 65 | _u8 negative; //Negative / Positive switched? 66 | 67 | //============================================================================= 68 | 69 | void gfx_delayed_settings(void) 70 | { 71 | //Window dimensions 72 | winx = ram[0x8002]; 73 | winy = ram[0x8003]; 74 | winw = ram[0x8004]; 75 | winh = ram[0x8005]; 76 | 77 | //Scroll Planes (Confirmed delayed) 78 | scroll1x = ram[0x8032]; 79 | scroll1y = ram[0x8033]; 80 | scroll2x = ram[0x8034]; 81 | scroll2y = ram[0x8035]; 82 | 83 | //Sprite offset (Confirmed delayed) 84 | scrollsprx = ram[0x8020]; 85 | scrollspry = ram[0x8021]; 86 | 87 | //Plane Priority (Confirmed delayed) 88 | planeSwap = ram[0x8030] & 0x80; 89 | 90 | //Background colour register (Confirmed delayed) 91 | bgc = ram[0x8118]; 92 | 93 | //2D Control register (Confirmed delayed) 94 | oowc = ram[0x8012] & 7; 95 | negative = ram[0x8012] & 0x80; 96 | } 97 | 98 | //============================================================================= 99 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015 Sergi Granell (xerpi) 3 | # based on Cirne's vita-toolchain test Makefile 4 | # 5 | 6 | TARGET := neopoppsp 7 | PSPAPP = System_PSP 8 | 9 | PSP_APP_NAME=NeoPopVITA 10 | PSP_APP_VER=0.71.15 11 | 12 | #SOURCES := src $(ZLIB) 13 | 14 | CORE=Core 15 | TLCS900=$(CORE)/TLCS-900h 16 | Z80=$(CORE)/z80 17 | 18 | SOURCES := System_PSP 19 | 20 | INCLUDES=-I$(SOURCES) -I$(Z80) -I$(TLCS900) -I$(SOURCES)/unzip/ -I$(CORE) 21 | 22 | BUILD_APP=$(Z80)/Z80.o $(Z80)/dasm.o $(CORE)/Z80_interface.o \ 23 | $(TLCS900)/TLCS900h_registers.o \ 24 | $(TLCS900)/TLCS900h_interpret_src.o \ 25 | $(TLCS900)/TLCS900h_interpret_single.o \ 26 | $(TLCS900)/TLCS900h_interpret_reg.o \ 27 | $(TLCS900)/TLCS900h_interpret_dst.o \ 28 | $(TLCS900)/TLCS900h_interpret.o \ 29 | $(TLCS900)/TLCS900h_disassemble_src.o \ 30 | $(TLCS900)/TLCS900h_disassemble_reg.o \ 31 | $(TLCS900)/TLCS900h_disassemble_extra.o \ 32 | $(TLCS900)/TLCS900h_disassemble_dst.o \ 33 | $(TLCS900)/TLCS900h_disassemble.o \ 34 | $(CORE)/dma.o $(CORE)/bios.o $(CORE)/biosHLE.o $(CORE)/mem.o \ 35 | $(CORE)/interrupt.o $(CORE)/gfx.o $(CORE)/sound.o \ 36 | $(CORE)/gfx_scanline_colour.o $(CORE)/gfx_scanline_mono.o \ 37 | $(CORE)/flash.o $(CORE)/rom.o $(CORE)/state.o $(CORE)/neopop.o 38 | BUILD_MZ=$(SOURCES)/unzip/ioapi.o $(SOURCES)/unzip/unzip.o 39 | BUILD_PORT=$(PSPAPP)/emulate.o $(PSPAPP)/emumenu.o $(PSPAPP)/neopop.o \ 40 | $(PSPAPP)/system_rom.o $(PSPAPP)/main.o 41 | 42 | 43 | OBJS=$(BUILD_APP) $(BUILD_MZ) $(BUILD_PORT) 44 | 45 | LIBS= -lpsplib -lvita2d -lfreetype -lpng -lz -lm -lSceSysmodule_stub -lSceCommonDialog_stub -lSceDisplay_stub -lSceGxm_stub \ 46 | -lSceCtrl_stub -lSceAudio_stub -lSceRtc_stub -lScePower_stub -lSceAppUtil_stub 47 | 48 | DEFINES = -DPSP -DPSP_APP_NAME=\"$(PSP_APP_NAME)\" -DPSP_APP_VER=\"$(PSP_APP_VER)\" \ 49 | -DCHIP_FREQUENCY=22050 -DZIPSUPPORT -Dint32=int32_t -Dint16=int16_t -Du32=uint32_t \ 50 | -Du64=uint64_t -DScePspDateTime=SceDateTime 51 | 52 | PREFIX = arm-vita-eabi 53 | AS = $(PREFIX)-as 54 | CC = $(PREFIX)-gcc 55 | CXX =$(PREFIX)-g++ 56 | READELF = $(PREFIX)-readelf 57 | OBJDUMP = $(PREFIX)-objdump 58 | CFLAGS = -Wl,-q -O3 $(INCLUDES) $(DEFINES) -fno-exceptions \ 59 | -fno-unwind-tables -fno-asynchronous-unwind-tables -ftree-vectorize \ 60 | -mfloat-abi=hard -ffast-math -fsingle-precision-constant -ftree-vectorizer-verbose=2 -fopt-info-vec-optimized -funroll-loops 61 | CXXFLAGS = $(CFLAGS) -fno-rtti -Wno-deprecated -Wno-comment -Wno-sequence-point 62 | ASFLAGS = $(CFLAGS) 63 | 64 | 65 | 66 | all: eboot.bin 67 | 68 | eboot.bin: $(TARGET).velf 69 | vita-make-fself $(TARGET).velf eboot.bin 70 | vita-mksfoex -s TITLE_ID=FRAN00004 "NeopopVITA" param.sfo 71 | 72 | $(TARGET).velf: $(TARGET).elf 73 | #advice from xyzz strip before create elf 74 | $(PREFIX)-strip -g $< 75 | #i put db.json there use your location 76 | vita-elf-create $< $@ 77 | 78 | $(TARGET).elf: $(OBJS) 79 | $(CC) $(CFLAGS) $(ASFLAGS) $^ $(LIBS) -o $@ 80 | 81 | clean: 82 | @rm -rf $(TARGET).elf $(TARGET).velf $(OBJS) $(DATA)/*.h 83 | 84 | copy: eboot.bin 85 | @cp eboot.bin param.sfo /mnt/shared/NeopopVITA 86 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret_dst.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret_dst.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef __TLCS900H_DST__ 35 | #define __TLCS900H_DST__ 36 | //========================================================================= 37 | 38 | //===== LD (mem),# 39 | void dstLDBi(void); 40 | 41 | //===== LD (mem),# 42 | void dstLDWi(void); 43 | 44 | //===== POP (mem) 45 | void dstPOPB(void); 46 | 47 | //===== POP (mem) 48 | void dstPOPW(void); 49 | 50 | //===== LD (mem),(nn) 51 | void dstLDBm16(void); 52 | 53 | //===== LD (mem),(nn) 54 | void dstLDWm16(void); 55 | 56 | //===== LDA R,mem 57 | void dstLDAW(void); 58 | 59 | //===== LDA R,mem 60 | void dstLDAL(void); 61 | 62 | //===== ANDCF A,(mem) 63 | void dstANDCFA(void); 64 | 65 | //===== ORCF A,(mem) 66 | void dstORCFA(void); 67 | 68 | //===== XORCF A,(mem) 69 | void dstXORCFA(void); 70 | 71 | //===== LDCF A,(mem) 72 | void dstLDCFA(void); 73 | 74 | //===== STCF A,(mem) 75 | void dstSTCFA(void); 76 | 77 | //===== LD (mem),R 78 | void dstLDBR(void); 79 | 80 | //===== LD (mem),R 81 | void dstLDWR(void); 82 | 83 | //===== LD (mem),R 84 | void dstLDLR(void); 85 | 86 | //===== ANDCF #3,(mem) 87 | void dstANDCF(void); 88 | 89 | //===== ORCF #3,(mem) 90 | void dstORCF(void); 91 | 92 | //===== XORCF #3,(mem) 93 | void dstXORCF(void); 94 | 95 | //===== LDCF #3,(mem) 96 | void dstLDCF(void); 97 | 98 | //===== STCF #3,(mem) 99 | void dstSTCF(void); 100 | 101 | //===== TSET #3,(mem) 102 | void dstTSET(void); 103 | 104 | //===== RES #3,(mem) 105 | void dstRES(void); 106 | 107 | //===== SET #3,(mem) 108 | void dstSET(void); 109 | 110 | //===== CHG #3,(mem) 111 | void dstCHG(void); 112 | 113 | //===== BIT #3,(mem) 114 | void dstBIT(void); 115 | 116 | //===== JP cc,mem 117 | void dstJP(void); 118 | 119 | //===== CALL cc,mem 120 | void dstCALL(void); 121 | 122 | //===== RET cc 123 | void dstRET(void); 124 | 125 | //========================================================================= 126 | #endif -------------------------------------------------------------------------------- /Core/z80/CodesXCB.h: -------------------------------------------------------------------------------- 1 | /** Z80: portable Z80 emulator *******************************/ 2 | /** **/ 3 | /** CodesXCB.h **/ 4 | /** **/ 5 | /** This file contains implementation for FD/DD-CB tables **/ 6 | /** of Z80 commands. It is included from Z80.c. **/ 7 | /** **/ 8 | /** Copyright (C) Marat Fayzullin 1994-2002 **/ 9 | /** You are not allowed to distribute this software **/ 10 | /** commercially. Please, notify me, if you make any **/ 11 | /** changes to this file. **/ 12 | /*************************************************************/ 13 | 14 | case RLC_xHL: I=RdZ80(J.W);M_RLC(I);WrZ80(J.W,I);break; 15 | case RRC_xHL: I=RdZ80(J.W);M_RRC(I);WrZ80(J.W,I);break; 16 | case RL_xHL: I=RdZ80(J.W);M_RL(I);WrZ80(J.W,I);break; 17 | case RR_xHL: I=RdZ80(J.W);M_RR(I);WrZ80(J.W,I);break; 18 | case SLA_xHL: I=RdZ80(J.W);M_SLA(I);WrZ80(J.W,I);break; 19 | case SRA_xHL: I=RdZ80(J.W);M_SRA(I);WrZ80(J.W,I);break; 20 | case SLL_xHL: I=RdZ80(J.W);M_SLL(I);WrZ80(J.W,I);break; 21 | case SRL_xHL: I=RdZ80(J.W);M_SRL(I);WrZ80(J.W,I);break; 22 | 23 | case BIT0_B: case BIT0_C: case BIT0_D: case BIT0_E: 24 | case BIT0_H: case BIT0_L: case BIT0_A: 25 | case BIT0_xHL: I=RdZ80(J.W);M_BIT(0,I);break; 26 | case BIT1_B: case BIT1_C: case BIT1_D: case BIT1_E: 27 | case BIT1_H: case BIT1_L: case BIT1_A: 28 | case BIT1_xHL: I=RdZ80(J.W);M_BIT(1,I);break; 29 | case BIT2_B: case BIT2_C: case BIT2_D: case BIT2_E: 30 | case BIT2_H: case BIT2_L: case BIT2_A: 31 | case BIT2_xHL: I=RdZ80(J.W);M_BIT(2,I);break; 32 | case BIT3_B: case BIT3_C: case BIT3_D: case BIT3_E: 33 | case BIT3_H: case BIT3_L: case BIT3_A: 34 | case BIT3_xHL: I=RdZ80(J.W);M_BIT(3,I);break; 35 | case BIT4_B: case BIT4_C: case BIT4_D: case BIT4_E: 36 | case BIT4_H: case BIT4_L: case BIT4_A: 37 | case BIT4_xHL: I=RdZ80(J.W);M_BIT(4,I);break; 38 | case BIT5_B: case BIT5_C: case BIT5_D: case BIT5_E: 39 | case BIT5_H: case BIT5_L: case BIT5_A: 40 | case BIT5_xHL: I=RdZ80(J.W);M_BIT(5,I);break; 41 | case BIT6_B: case BIT6_C: case BIT6_D: case BIT6_E: 42 | case BIT6_H: case BIT6_L: case BIT6_A: 43 | case BIT6_xHL: I=RdZ80(J.W);M_BIT(6,I);break; 44 | case BIT7_B: case BIT7_C: case BIT7_D: case BIT7_E: 45 | case BIT7_H: case BIT7_L: case BIT7_A: 46 | case BIT7_xHL: I=RdZ80(J.W);M_BIT(7,I);break; 47 | 48 | case RES0_xHL: I=RdZ80(J.W);M_RES(0,I);WrZ80(J.W,I);break; 49 | case RES1_xHL: I=RdZ80(J.W);M_RES(1,I);WrZ80(J.W,I);break; 50 | case RES2_xHL: I=RdZ80(J.W);M_RES(2,I);WrZ80(J.W,I);break; 51 | case RES3_xHL: I=RdZ80(J.W);M_RES(3,I);WrZ80(J.W,I);break; 52 | case RES4_xHL: I=RdZ80(J.W);M_RES(4,I);WrZ80(J.W,I);break; 53 | case RES5_xHL: I=RdZ80(J.W);M_RES(5,I);WrZ80(J.W,I);break; 54 | case RES6_xHL: I=RdZ80(J.W);M_RES(6,I);WrZ80(J.W,I);break; 55 | case RES7_xHL: I=RdZ80(J.W);M_RES(7,I);WrZ80(J.W,I);break; 56 | 57 | case SET0_xHL: I=RdZ80(J.W);M_SET(0,I);WrZ80(J.W,I);break; 58 | case SET1_xHL: I=RdZ80(J.W);M_SET(1,I);WrZ80(J.W,I);break; 59 | case SET2_xHL: I=RdZ80(J.W);M_SET(2,I);WrZ80(J.W,I);break; 60 | case SET3_xHL: I=RdZ80(J.W);M_SET(3,I);WrZ80(J.W,I);break; 61 | case SET4_xHL: I=RdZ80(J.W);M_SET(4,I);WrZ80(J.W,I);break; 62 | case SET5_xHL: I=RdZ80(J.W);M_SET(5,I);WrZ80(J.W,I);break; 63 | case SET6_xHL: I=RdZ80(J.W);M_SET(6,I);WrZ80(J.W,I);break; 64 | case SET7_xHL: I=RdZ80(J.W);M_SET(7,I);WrZ80(J.W,I);break; 65 | -------------------------------------------------------------------------------- /Core/state.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | state.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 21 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added all of the necessary #includes to this file. 34 | 35 | 25 JUL 2002 - neopop_uk 36 | ======================================= 37 | - Added comments to say that new state fields should be added to 38 | the end of the structure. 39 | 40 | 28 JUL 2002 - neopop_uk 41 | ======================================= 42 | - Renamed the state struct to NEOPOPSTATE0050 so that multiple versions 43 | can exist - should a new one be required. 44 | - Removed 'state_valid_id' as it's not used any more. 45 | 46 | 15 AUG 2002 - neopop_uk 47 | ======================================= 48 | - Changed the saved 'halt' bool into 'int reserved1'. 49 | - Changed 'int reserved1' into 'BOOL eepromStatusEnable' 50 | 51 | 18 AUG 2002 - neopop_uk 52 | ======================================= 53 | - Moved state_store/state_restore prototypes to NeoPop.h 54 | 55 | //--------------------------------------------------------------------------- 56 | */ 57 | 58 | #ifndef __STATE__ 59 | #define __STATE__ 60 | //============================================================================= 61 | 62 | #include "Z80_interface.h" //For Z80_regs 63 | #include "sound.h" //For SoundChip 64 | 65 | //----------------------------------------------------------------------------- 66 | // State Definitions: 67 | //----------------------------------------------------------------------------- 68 | 69 | typedef struct 70 | { 71 | //Save State Id 72 | _u16 valid_state_id; // = 0x0050 73 | 74 | //Memory 75 | _u8 ram[0xC000]; 76 | 77 | //TLCS-900h Registers 78 | _u32 pc; 79 | _u16 sr; 80 | _u8 f_dash; 81 | _u32 gprBank[4][4], gpr[4]; 82 | 83 | BOOL eepromStatusEnable; 84 | 85 | //Z80 Registers 86 | Z80 Z80_regs; 87 | 88 | //Timers 89 | _u32 timer_hint; 90 | _u8 timer[4]; //Up-counters 91 | _u32 timer_clock0, timer_clock1, timer_clock2, timer_clock3; 92 | 93 | //Sound Chips 94 | SoundChip toneChip; 95 | SoundChip noiseChip; 96 | 97 | //DMA 98 | _u32 dmaS[4], dmaD[4]; 99 | _u16 dmaC[4]; 100 | _u8 dmaM[4]; 101 | 102 | //Rom Description 103 | RomHeader header; 104 | } 105 | NEOPOPSTATE0050; 106 | 107 | //============================================================================= 108 | #endif 109 | 110 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret_single.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret_single.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef __TLCS900H_SINGLE__ 35 | #define __TLCS900H_SINGLE__ 36 | //========================================================================= 37 | 38 | //===== NOP 39 | void sngNOP(void); 40 | 41 | //===== NORMAL 42 | void sngNORMAL(void); 43 | 44 | //===== PUSH SR 45 | void sngPUSHSR(void); 46 | 47 | //===== POP SR 48 | void sngPOPSR(void); 49 | 50 | //===== MAX 51 | void sngMAX(void); 52 | 53 | //===== HALT 54 | void sngHALT(void); 55 | 56 | //===== EI #3 57 | void sngEI(void); 58 | 59 | //===== RETI 60 | void sngRETI(void); 61 | 62 | //===== LD (n), n 63 | void sngLD8_8(void); 64 | 65 | //===== PUSH n 66 | void sngPUSH8(void); 67 | 68 | //===== LD (n), nn 69 | void sngLD8_16(void); 70 | 71 | //===== PUSH nn 72 | void sngPUSH16(void); 73 | 74 | //===== INCF 75 | void sngINCF(void); 76 | 77 | //===== DECF 78 | void sngDECF(void); 79 | 80 | //===== RET condition 81 | void sngRET(void); 82 | 83 | //===== RETD dd 84 | void sngRETD(void); 85 | 86 | //===== RCF 87 | void sngRCF(void); 88 | 89 | //===== SCF 90 | void sngSCF(void); 91 | 92 | //===== CCF 93 | void sngCCF(void); 94 | 95 | //===== ZCF 96 | void sngZCF(void); 97 | 98 | //===== PUSH A 99 | void sngPUSHA(void); 100 | 101 | //===== POP A 102 | void sngPOPA(void); 103 | 104 | //===== EX F,F' 105 | void sngEX(void); 106 | 107 | //===== LDF #3 108 | void sngLDF(void); 109 | 110 | //===== PUSH F 111 | void sngPUSHF(void); 112 | 113 | //===== POP F 114 | void sngPOPF(void); 115 | 116 | //===== JP nn 117 | void sngJP16(void); 118 | 119 | //===== JP nnn 120 | void sngJP24(void); 121 | 122 | //===== CALL #16 123 | void sngCALL16(void); 124 | 125 | //===== CALL #24 126 | void sngCALL24(void); 127 | 128 | //===== CALR $+3+d16 129 | void sngCALR(void); 130 | 131 | //===== LD R, n 132 | void sngLDB(void); 133 | 134 | //===== PUSH RR 135 | void sngPUSHW(void); 136 | 137 | //===== LD RR, nn 138 | void sngLDW(void); 139 | 140 | //===== PUSH XRR 141 | void sngPUSHL(void); 142 | 143 | //===== LD XRR, nnnn 144 | void sngLDL(void); 145 | 146 | //===== POP RR 147 | void sngPOPW(void); 148 | 149 | //===== POP XRR 150 | void sngPOPL(void); 151 | 152 | //===== JR cc,PC + d 153 | void sngJR(void); 154 | 155 | //===== JR cc,PC + dd 156 | void sngJRL(void); 157 | 158 | //===== LDX dst,src 159 | void sngLDX(void); 160 | 161 | //===== SWI num 162 | void sngSWI(void); 163 | 164 | //============================================================================= 165 | #endif 166 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 21 AUG 2002 - neopop_uk 32 | ======================================= 33 | - Fixed potential precidence problems in regX and rCodeX by using ()'s 34 | 35 | //--------------------------------------------------------------------------- 36 | */ 37 | 38 | #ifndef __TLCS900H_REGISTERS__ 39 | #define __TLCS900H_REGISTERS__ 40 | //============================================================================= 41 | 42 | void reset_registers(void); 43 | void dump_registers_TLCS900h(void); 44 | 45 | //The value read by bad rCodes, leave 0, improves "Gals Fighters" 46 | #define RERR_VALUE 0 47 | 48 | //============================================================================= 49 | 50 | extern _u32 pc; 51 | extern _u16 sr; 52 | extern _u8 f_dash; 53 | 54 | extern _u32 gprBank[4][4], gpr[4]; 55 | 56 | extern _u32 rErr; 57 | 58 | extern _u8 statusRFP; 59 | 60 | //GPR Access 61 | extern _u8* gprMapB[4][8]; 62 | extern _u16* gprMapW[4][8]; 63 | extern _u32* gprMapL[4][8]; 64 | 65 | #define regB(x) (*(gprMapB[statusRFP][(x)])) 66 | #define regW(x) (*(gprMapW[statusRFP][(x)])) 67 | #define regL(x) (*(gprMapL[statusRFP][(x)])) 68 | 69 | //Reg.Code Access 70 | extern _u8* regCodeMapB[4][256]; 71 | extern _u16* regCodeMapW[4][128]; 72 | extern _u32* regCodeMapL[4][64]; 73 | 74 | #define rCodeB(r) (*(regCodeMapB[statusRFP][(r)])) 75 | #define rCodeW(r) (*(regCodeMapW[statusRFP][(r) >> 1])) 76 | #define rCodeL(r) (*(regCodeMapL[statusRFP][(r) >> 2])) 77 | 78 | //Common Registers 79 | #define REGA (regB(1)) 80 | #define REGWA (regW(0)) 81 | #define REGBC (regW(1)) 82 | #define REGXSP (gpr[3]) 83 | 84 | //============================================================================= 85 | 86 | _u8 statusIFF(void); 87 | void setStatusIFF(_u8 iff); 88 | 89 | void setStatusRFP(_u8 rfp); 90 | void changedSP(void); 91 | 92 | #define FLAG_S ((sr & 0x0080) >> 7) 93 | #define FLAG_Z ((sr & 0x0040) >> 6) 94 | #define FLAG_H ((sr & 0x0010) >> 4) 95 | #define FLAG_V ((sr & 0x0004) >> 2) 96 | #define FLAG_N ((sr & 0x0002) >> 1) 97 | #define FLAG_C (sr & 1) 98 | 99 | #define SETFLAG_S(s) { _u16 sr1 = sr & 0xFF7F; if (s) sr1 |= 0x0080; sr = sr1; } 100 | #define SETFLAG_Z(z) { _u16 sr1 = sr & 0xFFBF; if (z) sr1 |= 0x0040; sr = sr1; } 101 | #define SETFLAG_H(h) { _u16 sr1 = sr & 0xFFEF; if (h) sr1 |= 0x0010; sr = sr1; } 102 | #define SETFLAG_V(v) { _u16 sr1 = sr & 0xFFFB; if (v) sr1 |= 0x0004; sr = sr1; } 103 | #define SETFLAG_N(n) { _u16 sr1 = sr & 0xFFFD; if (n) sr1 |= 0x0002; sr = sr1; } 104 | #define SETFLAG_C(c) { _u16 sr1 = sr & 0xFFFE; if (c) sr1 |= 0x0001; sr = sr1; } 105 | 106 | #define SETFLAG_S0 { sr &= 0xFF7F; } 107 | #define SETFLAG_Z0 { sr &= 0xFFBF; } 108 | #define SETFLAG_H0 { sr &= 0xFFEF; } 109 | #define SETFLAG_V0 { sr &= 0xFFFB; } 110 | #define SETFLAG_N0 { sr &= 0xFFFD; } 111 | #define SETFLAG_C0 { sr &= 0xFFFE; } 112 | 113 | #define SETFLAG_S1 { sr |= 0x0080; } 114 | #define SETFLAG_Z1 { sr |= 0x0040; } 115 | #define SETFLAG_H1 { sr |= 0x0010; } 116 | #define SETFLAG_V1 { sr |= 0x0004; } 117 | #define SETFLAG_N1 { sr |= 0x0002; } 118 | #define SETFLAG_C1 { sr |= 0x0001; } 119 | 120 | //============================================================================= 121 | #endif 122 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret_src.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret_src.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef __TLCS900H_SRC__ 35 | #define __TLCS900H_SRC__ 36 | //========================================================================= 37 | 38 | //===== PUSH (mem) 39 | void srcPUSH(void); 40 | 41 | //===== RLD A,(mem) 42 | void srcRLD(void); 43 | 44 | //===== RRD A,(mem) 45 | void srcRRD(void); 46 | 47 | //===== LDI 48 | void srcLDI(void); 49 | 50 | //===== LDIR 51 | void srcLDIR(void); 52 | 53 | //===== LDD 54 | void srcLDD(void); 55 | 56 | //===== LDDR 57 | void srcLDDR(void); 58 | 59 | //===== CPI 60 | void srcCPI(void); 61 | 62 | //===== CPIR 63 | void srcCPIR(void); 64 | 65 | //===== CPD 66 | void srcCPD(void); 67 | 68 | //===== CPDR 69 | void srcCPDR(void); 70 | 71 | //===== LD (nn),(mem) 72 | void srcLD16m(void); 73 | 74 | //===== LD R,(mem) 75 | void srcLD(void); 76 | 77 | //===== EX (mem),R 78 | void srcEX(void); 79 | 80 | //===== ADD (mem),# 81 | void srcADDi(void); 82 | 83 | //===== ADC (mem),# 84 | void srcADCi(void); 85 | 86 | //===== SUB (mem),# 87 | void srcSUBi(void); 88 | 89 | //===== SBC (mem),# 90 | void srcSBCi(void); 91 | 92 | //===== AND (mem),# 93 | void srcANDi(void); 94 | 95 | //===== OR (mem),# 96 | void srcORi(void); 97 | 98 | //===== XOR (mem),# 99 | void srcXORi(void); 100 | 101 | //===== CP (mem),# 102 | void srcCPi(void); 103 | 104 | //===== MUL RR,(mem) 105 | void srcMUL(void); 106 | 107 | //===== MULS RR,(mem) 108 | void srcMULS(void); 109 | 110 | //===== DIV RR,(mem) 111 | void srcDIV(void); 112 | 113 | //===== DIVS RR,(mem) 114 | void srcDIVS(void); 115 | 116 | //===== INC #3,(mem) 117 | void srcINC(void); 118 | 119 | //===== DEC #3,(mem) 120 | void srcDEC(void); 121 | 122 | //===== RLC (mem) 123 | void srcRLC(void); 124 | 125 | //===== RRC (mem) 126 | void srcRRC(void); 127 | 128 | //===== RL (mem) 129 | void srcRL(void); 130 | 131 | //===== RR (mem) 132 | void srcRR(void); 133 | 134 | //===== SLA (mem) 135 | void srcSLA(void); 136 | 137 | //===== SRA (mem) 138 | void srcSRA(void); 139 | 140 | //===== SLL (mem) 141 | void srcSLL(void); 142 | 143 | //===== SRL (mem) 144 | void srcSRL(void); 145 | 146 | //===== ADD R,(mem) 147 | void srcADDRm(void); 148 | 149 | //===== ADD (mem),R 150 | void srcADDmR(void); 151 | 152 | //===== ADC R,(mem) 153 | void srcADCRm(void); 154 | 155 | //===== ADC (mem),R 156 | void srcADCmR(void); 157 | 158 | //===== SUB R,(mem) 159 | void srcSUBRm(void); 160 | 161 | //===== SUB (mem),R 162 | void srcSUBmR(void); 163 | 164 | //===== SBC R,(mem) 165 | void srcSBCRm(void); 166 | 167 | //===== SBC (mem),R 168 | void srcSBCmR(void); 169 | 170 | //===== AND R,(mem) 171 | void srcANDRm(void); 172 | 173 | //===== AND (mem),R 174 | void srcANDmR(void); 175 | 176 | //===== XOR R,(mem) 177 | void srcXORRm(void); 178 | 179 | //===== XOR (mem),R 180 | void srcXORmR(void); 181 | 182 | //===== OR R,(mem) 183 | void srcORRm(void); 184 | 185 | //===== OR (mem),R 186 | void srcORmR(void); 187 | 188 | //===== CP R,(mem) 189 | void srcCPRm(void); 190 | 191 | //===== CP (mem),R 192 | void srcCPmR(void); 193 | 194 | //============================================================================= 195 | #endif 196 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeW0.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeW0.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | (_u16*)(((_u8*)&gprBank[0][0]) + 0), (_u16*)(((_u8*)&gprBank[0][0]) + 2), 36 | (_u16*)(((_u8*)&gprBank[0][1]) + 0), (_u16*)(((_u8*)&gprBank[0][1]) + 2), 37 | (_u16*)(((_u8*)&gprBank[0][2]) + 0), (_u16*)(((_u8*)&gprBank[0][2]) + 2), 38 | (_u16*)(((_u8*)&gprBank[0][3]) + 0), (_u16*)(((_u8*)&gprBank[0][3]) + 2), 39 | 40 | //BANK 1 41 | (_u16*)(((_u8*)&gprBank[1][0]) + 0), (_u16*)(((_u8*)&gprBank[1][0]) + 2), 42 | (_u16*)(((_u8*)&gprBank[1][1]) + 0), (_u16*)(((_u8*)&gprBank[1][1]) + 2), 43 | (_u16*)(((_u8*)&gprBank[1][2]) + 0), (_u16*)(((_u8*)&gprBank[1][2]) + 2), 44 | (_u16*)(((_u8*)&gprBank[1][3]) + 0), (_u16*)(((_u8*)&gprBank[1][3]) + 2), 45 | 46 | //BANK 2 47 | (_u16*)(((_u8*)&gprBank[2][0]) + 0), (_u16*)(((_u8*)&gprBank[2][0]) + 2), 48 | (_u16*)(((_u8*)&gprBank[2][1]) + 0), (_u16*)(((_u8*)&gprBank[2][1]) + 2), 49 | (_u16*)(((_u8*)&gprBank[2][2]) + 0), (_u16*)(((_u8*)&gprBank[2][2]) + 2), 50 | (_u16*)(((_u8*)&gprBank[2][3]) + 0), (_u16*)(((_u8*)&gprBank[2][3]) + 2), 51 | 52 | //BANK 3 53 | (_u16*)(((_u8*)&gprBank[3][0]) + 0), (_u16*)(((_u8*)&gprBank[3][0]) + 2), 54 | (_u16*)(((_u8*)&gprBank[3][1]) + 0), (_u16*)(((_u8*)&gprBank[3][1]) + 2), 55 | (_u16*)(((_u8*)&gprBank[3][2]) + 0), (_u16*)(((_u8*)&gprBank[3][2]) + 2), 56 | (_u16*)(((_u8*)&gprBank[3][3]) + 0), (_u16*)(((_u8*)&gprBank[3][3]) + 2), 57 | 58 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 59 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 60 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 61 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 62 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 63 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 64 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 65 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 66 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 67 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 68 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 69 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 70 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 71 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 72 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 73 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 74 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 75 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 76 | 77 | //Previous Bank 78 | (_u16*)&rErr,(_u16*)&rErr, 79 | (_u16*)&rErr,(_u16*)&rErr, 80 | (_u16*)&rErr,(_u16*)&rErr, 81 | (_u16*)&rErr,(_u16*)&rErr, 82 | 83 | //Current Bank 84 | (_u16*)(((_u8*)&gprBank[0][0]) + 0), (_u16*)(((_u8*)&gprBank[0][0]) + 2), 85 | (_u16*)(((_u8*)&gprBank[0][1]) + 0), (_u16*)(((_u8*)&gprBank[0][1]) + 2), 86 | (_u16*)(((_u8*)&gprBank[0][2]) + 0), (_u16*)(((_u8*)&gprBank[0][2]) + 2), 87 | (_u16*)(((_u8*)&gprBank[0][3]) + 0), (_u16*)(((_u8*)&gprBank[0][3]) + 2), 88 | 89 | (_u16*)((_u8*)&(gpr[0]) + 0), (_u16*)((_u8*)&(gpr[0]) + 2), 90 | (_u16*)((_u8*)&(gpr[1]) + 0), (_u16*)((_u8*)&(gpr[1]) + 2), 91 | (_u16*)((_u8*)&(gpr[2]) + 0), (_u16*)((_u8*)&(gpr[2]) + 2), 92 | (_u16*)((_u8*)&(gpr[3]) + 0), (_u16*)((_u8*)&(gpr[3]) + 2), 93 | 94 | //============================================================================= 95 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 21 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added the 'instruction_error' function declaration here. 34 | 35 | 28 JUL 2002 - neopop_uk 36 | ======================================= 37 | - Removed CYCLE_WARNING as it is now obsolete. 38 | - Added generic DIV prototypes. 39 | 40 | //--------------------------------------------------------------------------- 41 | */ 42 | 43 | #ifndef __TLCS900H_INTERPRET__ 44 | #define __TLCS900H_INTERPRET__ 45 | //============================================================================= 46 | 47 | //Interprets a single instruction from 'pc', 48 | //pc is incremented to the start of the next instruction. 49 | //Returns the number of cycles taken for this instruction 50 | _u8 TLCS900h_interpret(void); 51 | 52 | //============================================================================= 53 | 54 | extern _u32 mem; 55 | extern int size; 56 | extern _u8 first; //First byte 57 | extern _u8 second; //Second byte 58 | extern _u8 R; //(second & 7) 59 | extern _u8 rCode; 60 | extern _u8 cycles; 61 | extern BOOL brCode; 62 | 63 | //============================================================================= 64 | 65 | void __cdecl instruction_error(char* vaMessage,...); 66 | 67 | //============================================================================= 68 | 69 | //#define FETCH8 loadB(pc++) 70 | #define FETCH8 loadBRom(pc++) 71 | 72 | _u16 fetch16(void); 73 | _u32 fetch24(void); 74 | _u32 fetch32(void); 75 | 76 | //============================================================================= 77 | 78 | void parityB(_u8 value); 79 | void parityW(_u16 value); 80 | 81 | //============================================================================= 82 | 83 | void push8(_u8 data); 84 | void push16(_u16 data); 85 | void push32(_u32 data); 86 | 87 | _u8 pop8(void); 88 | _u16 pop16(void); 89 | _u32 pop32(void); 90 | 91 | //============================================================================= 92 | 93 | //DIV =============== 94 | _u16 generic_DIV_B(_u16 val, _u8 div); 95 | _u32 generic_DIV_W(_u32 val, _u16 div); 96 | 97 | //DIVS =============== 98 | _u16 generic_DIVS_B(_s16 val, _s8 div); 99 | _u32 generic_DIVS_W(_s32 val, _s16 div); 100 | 101 | //ADD =============== 102 | _u8 generic_ADD_B(_u8 dst, _u8 src); 103 | _u16 generic_ADD_W(_u16 dst, _u16 src); 104 | _u32 generic_ADD_L(_u32 dst, _u32 src); 105 | 106 | //ADC =============== 107 | _u8 generic_ADC_B(_u8 dst, _u8 src); 108 | _u16 generic_ADC_W(_u16 dst, _u16 src); 109 | _u32 generic_ADC_L(_u32 dst, _u32 src); 110 | 111 | //SUB =============== 112 | _u8 generic_SUB_B(_u8 dst, _u8 src); 113 | _u16 generic_SUB_W(_u16 dst, _u16 src); 114 | _u32 generic_SUB_L(_u32 dst, _u32 src); 115 | 116 | //SBC =============== 117 | _u8 generic_SBC_B(_u8 dst, _u8 src); 118 | _u16 generic_SBC_W(_u16 dst, _u16 src); 119 | _u32 generic_SBC_L(_u32 dst, _u32 src); 120 | 121 | //============================================================================= 122 | 123 | //Confirms a condition code check 124 | BOOL conditionCode(int cc); 125 | 126 | //============================================================================= 127 | 128 | //Translate an rr or RR value for MUL/MULS/DIV/DIVS 129 | _u8 get_rr_Target(void); 130 | _u8 get_RR_Target(void); 131 | 132 | //============================================================================= 133 | #endif 134 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 10 AUG 2002 - neopop_uk 32 | ======================================= 33 | - Moved default PC setup to the 'reset_registers' function. 34 | 35 | //--------------------------------------------------------------------------- 36 | */ 37 | 38 | #include "neopop.h" 39 | #include "TLCS900h_registers.h" 40 | 41 | //============================================================================= 42 | 43 | _u32 pc, gprBank[4][4], gpr[4]; 44 | _u16 sr; 45 | _u8 f_dash; 46 | 47 | //============================================================================= 48 | 49 | //Bank Data 50 | _u8* gprMapB[4][8] = 51 | { 52 | #include "TLCS900h_registers_mapB.h" 53 | }; 54 | 55 | _u16* gprMapW[4][8] = 56 | { 57 | #include "TLCS900h_registers_mapW.h" 58 | }; 59 | 60 | _u32* gprMapL[4][8] = 61 | { 62 | #include "TLCS900h_registers_mapL.h" 63 | }; 64 | 65 | //============================================================================= 66 | 67 | _u32 rErr; 68 | 69 | _u8* regCodeMapB[4][256] = 70 | { 71 | { 72 | #include "TLCS900h_registers_mapCodeB0.h" 73 | }, 74 | 75 | { 76 | #include "TLCS900h_registers_mapCodeB1.h" 77 | }, 78 | 79 | { 80 | #include "TLCS900h_registers_mapCodeB2.h" 81 | }, 82 | 83 | { 84 | #include "TLCS900h_registers_mapCodeB3.h" 85 | } 86 | }; 87 | 88 | _u16* regCodeMapW[4][128] = 89 | { 90 | { 91 | #include "TLCS900h_registers_mapCodeW0.h" 92 | }, 93 | 94 | { 95 | #include "TLCS900h_registers_mapCodeW1.h" 96 | }, 97 | 98 | { 99 | #include "TLCS900h_registers_mapCodeW2.h" 100 | }, 101 | 102 | { 103 | #include "TLCS900h_registers_mapCodeW3.h" 104 | } 105 | }; 106 | 107 | _u32* regCodeMapL[4][64] = 108 | { 109 | { 110 | #include "TLCS900h_registers_mapCodeL0.h" 111 | }, 112 | 113 | { 114 | #include "TLCS900h_registers_mapCodeL1.h" 115 | }, 116 | 117 | { 118 | #include "TLCS900h_registers_mapCodeL2.h" 119 | }, 120 | 121 | { 122 | #include "TLCS900h_registers_mapCodeL3.h" 123 | } 124 | }; 125 | 126 | //============================================================================= 127 | 128 | _u8 statusIFF(void) 129 | { 130 | _u8 iff = (sr & 0x7000) >> 12; 131 | 132 | if (iff == 1) 133 | return 0; 134 | else 135 | return iff; 136 | } 137 | 138 | void setStatusIFF(_u8 iff) 139 | { 140 | sr = (sr & 0x8FFF) | ((iff & 0x7) << 12); 141 | } 142 | 143 | //============================================================================= 144 | 145 | _u8 statusRFP; 146 | 147 | void setStatusRFP(_u8 rfp) 148 | { 149 | sr = (sr & 0xF8FF) | ((rfp & 0x3) << 8); 150 | changedSP(); 151 | } 152 | 153 | void changedSP(void) 154 | { 155 | //Store global RFP for optimisation. 156 | statusRFP = ((sr & 0x300) >> 8); 157 | } 158 | 159 | //============================================================================= 160 | 161 | void reset_registers(void) 162 | { 163 | memset(gprBank, 0, sizeof(gprBank)); 164 | memset(gpr, 0, sizeof(gpr)); 165 | 166 | if (rom.data) 167 | pc = rom_header->startPC & 0xFFFFFF; 168 | else 169 | pc = 0xFFFFFE; 170 | 171 | sr = 0xF800; // = %11111000???????? (?) are undefined in the manual) 172 | changedSP(); 173 | 174 | f_dash = 00; 175 | 176 | rErr = RERR_VALUE; 177 | 178 | REGXSP = 0x00006C00; //Confirmed from BIOS, 179 | //immediately changes value from default of 0x100 180 | } 181 | 182 | //============================================================================= 183 | -------------------------------------------------------------------------------- /System_PSP/unzip/ioapi.c: -------------------------------------------------------------------------------- 1 | /* ioapi.c -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.00, September 10th, 2003 5 | 6 | Copyright (C) 1998-2003 Gilles Vollant 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "zlib.h" 14 | #include "ioapi.h" 15 | 16 | #include 17 | #include 18 | 19 | 20 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ 21 | 22 | #ifndef SEEK_CUR 23 | #define SEEK_CUR 1 24 | #endif 25 | 26 | #ifndef SEEK_END 27 | #define SEEK_END 2 28 | #endif 29 | 30 | #ifndef SEEK_SET 31 | #define SEEK_SET 0 32 | #endif 33 | 34 | voidpf ZCALLBACK fopen_file_func OF(( 35 | voidpf opaque, 36 | const char* filename, 37 | int mode)); 38 | 39 | uLong ZCALLBACK fread_file_func OF(( 40 | voidpf opaque, 41 | voidpf stream, 42 | void* buf, 43 | uLong size)); 44 | 45 | uLong ZCALLBACK fwrite_file_func OF(( 46 | voidpf opaque, 47 | voidpf stream, 48 | const void* buf, 49 | uLong size)); 50 | 51 | long ZCALLBACK ftell_file_func OF(( 52 | voidpf opaque, 53 | voidpf stream)); 54 | 55 | long ZCALLBACK fseek_file_func OF(( 56 | voidpf opaque, 57 | voidpf stream, 58 | uLong offset, 59 | int origin)); 60 | 61 | int ZCALLBACK fclose_file_func OF(( 62 | voidpf opaque, 63 | voidpf stream)); 64 | 65 | int ZCALLBACK ferror_file_func OF(( 66 | voidpf opaque, 67 | voidpf stream)); 68 | 69 | 70 | voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) 71 | voidpf opaque; 72 | const char* filename; 73 | int mode; 74 | { 75 | SceUID file = NULL; 76 | int mode_fopen = 0; 77 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) 78 | mode_fopen = SCE_O_RDONLY; 79 | else 80 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) 81 | mode_fopen = SCE_O_RDWR; 82 | else 83 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) 84 | mode_fopen = SCE_O_WRONLY | SCE_O_CREAT; 85 | 86 | if ((filename!=NULL) && (mode_fopen != 0)) 87 | file = sceIoOpen(filename, mode_fopen, 0777); 88 | return file; 89 | } 90 | 91 | 92 | uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) 93 | voidpf opaque; 94 | voidpf stream; 95 | void* buf; 96 | uLong size; 97 | { 98 | uLong ret; 99 | ret = sceIoRead((SceUID)stream, buf, (size_t)size); 100 | return ret; 101 | } 102 | 103 | 104 | uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) 105 | voidpf opaque; 106 | voidpf stream; 107 | const void* buf; 108 | uLong size; 109 | { 110 | uLong ret; 111 | ret = sceIoRead((SceUID)stream, buf, (size_t)size); 112 | return ret; 113 | } 114 | 115 | long ZCALLBACK ftell_file_func (opaque, stream) 116 | voidpf opaque; 117 | voidpf stream; 118 | { 119 | long ret; 120 | ret = sceIoLseek((SceUID)stream,0,SCE_SEEK_END); 121 | sceIoLseek((SceUID)stream,0,SCE_SEEK_SET); 122 | return ret; 123 | } 124 | 125 | long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) 126 | voidpf opaque; 127 | voidpf stream; 128 | uLong offset; 129 | int origin; 130 | { 131 | int fseek_origin=0; 132 | long ret; 133 | switch (origin) 134 | { 135 | case ZLIB_FILEFUNC_SEEK_CUR : 136 | fseek_origin = SCE_SEEK_CUR; 137 | break; 138 | case ZLIB_FILEFUNC_SEEK_END : 139 | fseek_origin = SCE_SEEK_END; 140 | break; 141 | case ZLIB_FILEFUNC_SEEK_SET : 142 | fseek_origin = SCE_SEEK_SET; 143 | break; 144 | default: return -1; 145 | } 146 | ret = 0; 147 | sceIoLseek((SceUID)stream,offset,fseek_origin); 148 | return ret; 149 | } 150 | 151 | int ZCALLBACK fclose_file_func (opaque, stream) 152 | voidpf opaque; 153 | voidpf stream; 154 | { 155 | int ret; 156 | ret = sceIoClose((SceUID)stream); 157 | return ret; 158 | } 159 | 160 | int ZCALLBACK ferror_file_func (opaque, stream) 161 | voidpf opaque; 162 | voidpf stream; 163 | { 164 | int ret = 0; 165 | //ret = ferror((FILE *)stream); 166 | return ret; 167 | } 168 | 169 | void fill_fopen_filefunc (pzlib_filefunc_def) 170 | zlib_filefunc_def* pzlib_filefunc_def; 171 | { 172 | pzlib_filefunc_def->zopen_file = fopen_file_func; 173 | pzlib_filefunc_def->zread_file = fread_file_func; 174 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; 175 | pzlib_filefunc_def->ztell_file = ftell_file_func; 176 | pzlib_filefunc_def->zseek_file = fseek_file_func; 177 | pzlib_filefunc_def->zclose_file = fclose_file_func; 178 | pzlib_filefunc_def->zerror_file = ferror_file_func; 179 | pzlib_filefunc_def->opaque = NULL; 180 | } 181 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeW1.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeW1.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | (_u16*)(((_u8*)&gprBank[0][0]) + 0), (_u16*)(((_u8*)&gprBank[0][0]) + 2), 36 | (_u16*)(((_u8*)&gprBank[0][1]) + 0), (_u16*)(((_u8*)&gprBank[0][1]) + 2), 37 | (_u16*)(((_u8*)&gprBank[0][2]) + 0), (_u16*)(((_u8*)&gprBank[0][2]) + 2), 38 | (_u16*)(((_u8*)&gprBank[0][3]) + 0), (_u16*)(((_u8*)&gprBank[0][3]) + 2), 39 | 40 | //BANK 1 41 | (_u16*)(((_u8*)&gprBank[1][0]) + 0), (_u16*)(((_u8*)&gprBank[1][0]) + 2), 42 | (_u16*)(((_u8*)&gprBank[1][1]) + 0), (_u16*)(((_u8*)&gprBank[1][1]) + 2), 43 | (_u16*)(((_u8*)&gprBank[1][2]) + 0), (_u16*)(((_u8*)&gprBank[1][2]) + 2), 44 | (_u16*)(((_u8*)&gprBank[1][3]) + 0), (_u16*)(((_u8*)&gprBank[1][3]) + 2), 45 | 46 | //BANK 2 47 | (_u16*)(((_u8*)&gprBank[2][0]) + 0), (_u16*)(((_u8*)&gprBank[2][0]) + 2), 48 | (_u16*)(((_u8*)&gprBank[2][1]) + 0), (_u16*)(((_u8*)&gprBank[2][1]) + 2), 49 | (_u16*)(((_u8*)&gprBank[2][2]) + 0), (_u16*)(((_u8*)&gprBank[2][2]) + 2), 50 | (_u16*)(((_u8*)&gprBank[2][3]) + 0), (_u16*)(((_u8*)&gprBank[2][3]) + 2), 51 | 52 | //BANK 3 53 | (_u16*)(((_u8*)&gprBank[3][0]) + 0), (_u16*)(((_u8*)&gprBank[3][0]) + 2), 54 | (_u16*)(((_u8*)&gprBank[3][1]) + 0), (_u16*)(((_u8*)&gprBank[3][1]) + 2), 55 | (_u16*)(((_u8*)&gprBank[3][2]) + 0), (_u16*)(((_u8*)&gprBank[3][2]) + 2), 56 | (_u16*)(((_u8*)&gprBank[3][3]) + 0), (_u16*)(((_u8*)&gprBank[3][3]) + 2), 57 | 58 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 59 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 60 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 61 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 62 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 63 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 64 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 65 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 66 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 67 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 68 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 69 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 70 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 71 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 72 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 73 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 74 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 75 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 76 | 77 | //Previous Bank 78 | (_u16*)(((_u8*)&gprBank[0][0]) + 0), (_u16*)(((_u8*)&gprBank[0][0]) + 2), 79 | (_u16*)(((_u8*)&gprBank[0][1]) + 0), (_u16*)(((_u8*)&gprBank[0][1]) + 2), 80 | (_u16*)(((_u8*)&gprBank[0][2]) + 0), (_u16*)(((_u8*)&gprBank[0][2]) + 2), 81 | (_u16*)(((_u8*)&gprBank[0][3]) + 0), (_u16*)(((_u8*)&gprBank[0][3]) + 2), 82 | 83 | //Current Bank 84 | (_u16*)(((_u8*)&gprBank[1][0]) + 0), (_u16*)(((_u8*)&gprBank[1][0]) + 2), 85 | (_u16*)(((_u8*)&gprBank[1][1]) + 0), (_u16*)(((_u8*)&gprBank[1][1]) + 2), 86 | (_u16*)(((_u8*)&gprBank[1][2]) + 0), (_u16*)(((_u8*)&gprBank[1][2]) + 2), 87 | (_u16*)(((_u8*)&gprBank[1][3]) + 0), (_u16*)(((_u8*)&gprBank[1][3]) + 2), 88 | 89 | (_u16*)((_u8*)&(gpr[0]) + 0), (_u16*)((_u8*)&(gpr[0]) + 2), 90 | (_u16*)((_u8*)&(gpr[1]) + 0), (_u16*)((_u8*)&(gpr[1]) + 2), 91 | (_u16*)((_u8*)&(gpr[2]) + 0), (_u16*)((_u8*)&(gpr[2]) + 2), 92 | (_u16*)((_u8*)&(gpr[3]) + 0), (_u16*)((_u8*)&(gpr[3]) + 2), 93 | 94 | //============================================================================= 95 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeW2.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeW2.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | (_u16*)(((_u8*)&gprBank[0][0]) + 0), (_u16*)(((_u8*)&gprBank[0][0]) + 2), 36 | (_u16*)(((_u8*)&gprBank[0][1]) + 0), (_u16*)(((_u8*)&gprBank[0][1]) + 2), 37 | (_u16*)(((_u8*)&gprBank[0][2]) + 0), (_u16*)(((_u8*)&gprBank[0][2]) + 2), 38 | (_u16*)(((_u8*)&gprBank[0][3]) + 0), (_u16*)(((_u8*)&gprBank[0][3]) + 2), 39 | 40 | //BANK 1 41 | (_u16*)(((_u8*)&gprBank[1][0]) + 0), (_u16*)(((_u8*)&gprBank[1][0]) + 2), 42 | (_u16*)(((_u8*)&gprBank[1][1]) + 0), (_u16*)(((_u8*)&gprBank[1][1]) + 2), 43 | (_u16*)(((_u8*)&gprBank[1][2]) + 0), (_u16*)(((_u8*)&gprBank[1][2]) + 2), 44 | (_u16*)(((_u8*)&gprBank[1][3]) + 0), (_u16*)(((_u8*)&gprBank[1][3]) + 2), 45 | 46 | //BANK 2 47 | (_u16*)(((_u8*)&gprBank[2][0]) + 0), (_u16*)(((_u8*)&gprBank[2][0]) + 2), 48 | (_u16*)(((_u8*)&gprBank[2][1]) + 0), (_u16*)(((_u8*)&gprBank[2][1]) + 2), 49 | (_u16*)(((_u8*)&gprBank[2][2]) + 0), (_u16*)(((_u8*)&gprBank[2][2]) + 2), 50 | (_u16*)(((_u8*)&gprBank[2][3]) + 0), (_u16*)(((_u8*)&gprBank[2][3]) + 2), 51 | 52 | //BANK 3 53 | (_u16*)(((_u8*)&gprBank[3][0]) + 0), (_u16*)(((_u8*)&gprBank[3][0]) + 2), 54 | (_u16*)(((_u8*)&gprBank[3][1]) + 0), (_u16*)(((_u8*)&gprBank[3][1]) + 2), 55 | (_u16*)(((_u8*)&gprBank[3][2]) + 0), (_u16*)(((_u8*)&gprBank[3][2]) + 2), 56 | (_u16*)(((_u8*)&gprBank[3][3]) + 0), (_u16*)(((_u8*)&gprBank[3][3]) + 2), 57 | 58 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 59 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 60 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 61 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 62 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 63 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 64 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 65 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 66 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 67 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 68 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 69 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 70 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 71 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 72 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 73 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 74 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 75 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 76 | 77 | //Previous Bank 78 | (_u16*)(((_u8*)&gprBank[1][0]) + 0), (_u16*)(((_u8*)&gprBank[1][0]) + 2), 79 | (_u16*)(((_u8*)&gprBank[1][1]) + 0), (_u16*)(((_u8*)&gprBank[1][1]) + 2), 80 | (_u16*)(((_u8*)&gprBank[1][2]) + 0), (_u16*)(((_u8*)&gprBank[1][2]) + 2), 81 | (_u16*)(((_u8*)&gprBank[1][3]) + 0), (_u16*)(((_u8*)&gprBank[1][3]) + 2), 82 | 83 | //Current Bank 84 | (_u16*)(((_u8*)&gprBank[2][0]) + 0), (_u16*)(((_u8*)&gprBank[2][0]) + 2), 85 | (_u16*)(((_u8*)&gprBank[2][1]) + 0), (_u16*)(((_u8*)&gprBank[2][1]) + 2), 86 | (_u16*)(((_u8*)&gprBank[2][2]) + 0), (_u16*)(((_u8*)&gprBank[2][2]) + 2), 87 | (_u16*)(((_u8*)&gprBank[2][3]) + 0), (_u16*)(((_u8*)&gprBank[2][3]) + 2), 88 | 89 | (_u16*)((_u8*)&(gpr[0]) + 0), (_u16*)((_u8*)&(gpr[0]) + 2), 90 | (_u16*)((_u8*)&(gpr[1]) + 0), (_u16*)((_u8*)&(gpr[1]) + 2), 91 | (_u16*)((_u8*)&(gpr[2]) + 0), (_u16*)((_u8*)&(gpr[2]) + 2), 92 | (_u16*)((_u8*)&(gpr[3]) + 0), (_u16*)((_u8*)&(gpr[3]) + 2), 93 | 94 | //============================================================================= 95 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeW3.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeW3.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | //BANK 0 35 | (_u16*)(((_u8*)&gprBank[0][0]) + 0), (_u16*)(((_u8*)&gprBank[0][0]) + 2), 36 | (_u16*)(((_u8*)&gprBank[0][1]) + 0), (_u16*)(((_u8*)&gprBank[0][1]) + 2), 37 | (_u16*)(((_u8*)&gprBank[0][2]) + 0), (_u16*)(((_u8*)&gprBank[0][2]) + 2), 38 | (_u16*)(((_u8*)&gprBank[0][3]) + 0), (_u16*)(((_u8*)&gprBank[0][3]) + 2), 39 | 40 | //BANK 1 41 | (_u16*)(((_u8*)&gprBank[1][0]) + 0), (_u16*)(((_u8*)&gprBank[1][0]) + 2), 42 | (_u16*)(((_u8*)&gprBank[1][1]) + 0), (_u16*)(((_u8*)&gprBank[1][1]) + 2), 43 | (_u16*)(((_u8*)&gprBank[1][2]) + 0), (_u16*)(((_u8*)&gprBank[1][2]) + 2), 44 | (_u16*)(((_u8*)&gprBank[1][3]) + 0), (_u16*)(((_u8*)&gprBank[1][3]) + 2), 45 | 46 | //BANK 2 47 | (_u16*)(((_u8*)&gprBank[2][0]) + 0), (_u16*)(((_u8*)&gprBank[2][0]) + 2), 48 | (_u16*)(((_u8*)&gprBank[2][1]) + 0), (_u16*)(((_u8*)&gprBank[2][1]) + 2), 49 | (_u16*)(((_u8*)&gprBank[2][2]) + 0), (_u16*)(((_u8*)&gprBank[2][2]) + 2), 50 | (_u16*)(((_u8*)&gprBank[2][3]) + 0), (_u16*)(((_u8*)&gprBank[2][3]) + 2), 51 | 52 | //BANK 3 53 | (_u16*)(((_u8*)&gprBank[3][0]) + 0), (_u16*)(((_u8*)&gprBank[3][0]) + 2), 54 | (_u16*)(((_u8*)&gprBank[3][1]) + 0), (_u16*)(((_u8*)&gprBank[3][1]) + 2), 55 | (_u16*)(((_u8*)&gprBank[3][2]) + 0), (_u16*)(((_u8*)&gprBank[3][2]) + 2), 56 | (_u16*)(((_u8*)&gprBank[3][3]) + 0), (_u16*)(((_u8*)&gprBank[3][3]) + 2), 57 | 58 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 59 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 60 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 61 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 62 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 63 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 64 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 65 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 66 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 67 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 68 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 69 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 70 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 71 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 72 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 73 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 74 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 75 | (_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr,(_u16*)&rErr, 76 | 77 | //Previous Bank 78 | (_u16*)(((_u8*)&gprBank[2][0]) + 0), (_u16*)(((_u8*)&gprBank[2][0]) + 2), 79 | (_u16*)(((_u8*)&gprBank[2][1]) + 0), (_u16*)(((_u8*)&gprBank[2][1]) + 2), 80 | (_u16*)(((_u8*)&gprBank[2][2]) + 0), (_u16*)(((_u8*)&gprBank[2][2]) + 2), 81 | (_u16*)(((_u8*)&gprBank[2][3]) + 0), (_u16*)(((_u8*)&gprBank[2][3]) + 2), 82 | 83 | //Current Bank 84 | (_u16*)(((_u8*)&gprBank[3][0]) + 0), (_u16*)(((_u8*)&gprBank[3][0]) + 2), 85 | (_u16*)(((_u8*)&gprBank[3][1]) + 0), (_u16*)(((_u8*)&gprBank[3][1]) + 2), 86 | (_u16*)(((_u8*)&gprBank[3][2]) + 0), (_u16*)(((_u8*)&gprBank[3][2]) + 2), 87 | (_u16*)(((_u8*)&gprBank[3][3]) + 0), (_u16*)(((_u8*)&gprBank[3][3]) + 2), 88 | 89 | (_u16*)((_u8*)&(gpr[0]) + 0), (_u16*)((_u8*)&(gpr[0]) + 2), 90 | (_u16*)((_u8*)&(gpr[1]) + 0), (_u16*)((_u8*)&(gpr[1]) + 2), 91 | (_u16*)((_u8*)&(gpr[2]) + 0), (_u16*)((_u8*)&(gpr[2]) + 2), 92 | (_u16*)((_u8*)&(gpr[3]) + 0), (_u16*)((_u8*)&(gpr[3]) + 2), 93 | 94 | //============================================================================= 95 | -------------------------------------------------------------------------------- /System_PSP/unzip/crypt.h: -------------------------------------------------------------------------------- 1 | /* crypt.h -- base code for crypt/uncrypt ZIPfile 2 | 3 | 4 | Version 1.00, September 10th, 2003 5 | 6 | Copyright (C) 1998-2003 Gilles Vollant 7 | 8 | This code is a modified version of crypting code in Infozip distribution 9 | 10 | The encryption/decryption parts of this source code (as opposed to the 11 | non-echoing password parts) were originally written in Europe. The 12 | whole source package can be freely distributed, including from the USA. 13 | (Prior to January 2000, re-export from the US was a violation of US law.) 14 | 15 | This encryption code is a direct transcription of the algorithm from 16 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This 17 | file (appnote.txt) is distributed with the PKZIP program (even in the 18 | version without encryption capabilities). 19 | 20 | If you don't need crypting in your application, just define symbols 21 | NOCRYPT and NOUNCRYPT. 22 | 23 | This code support the "Traditional PKWARE Encryption". 24 | 25 | The new AES encryption added on Zip format by Winzip (see the page 26 | http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong 27 | Encryption is not supported. 28 | */ 29 | 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) 31 | 32 | /*********************************************************************** 33 | * Return the next byte in the pseudo-random sequence 34 | */ 35 | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) 36 | { 37 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an 38 | * unpredictable manner on 16-bit systems; not a problem 39 | * with any known compiler so far, though */ 40 | 41 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; 42 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); 43 | } 44 | 45 | /*********************************************************************** 46 | * Update the encryption keys with the next byte of plain text 47 | */ 48 | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) 49 | { 50 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); 51 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; 52 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; 53 | { 54 | register int keyshift = (int)((*(pkeys+1)) >> 24); 55 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); 56 | } 57 | return c; 58 | } 59 | 60 | 61 | /*********************************************************************** 62 | * Initialize the encryption keys and the random header according to 63 | * the given password. 64 | */ 65 | static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) 66 | { 67 | *(pkeys+0) = 305419896L; 68 | *(pkeys+1) = 591751049L; 69 | *(pkeys+2) = 878082192L; 70 | while (*passwd != '\0') { 71 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); 72 | passwd++; 73 | } 74 | } 75 | 76 | #define zdecode(pkeys,pcrc_32_tab,c) \ 77 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) 78 | 79 | #define zencode(pkeys,pcrc_32_tab,c,t) \ 80 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) 81 | 82 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED 83 | 84 | #define RAND_HEAD_LEN 12 85 | /* "last resort" source for second part of crypt seed pattern */ 86 | # ifndef ZCR_SEED2 87 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ 88 | # endif 89 | 90 | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) 91 | const char *passwd; /* password string */ 92 | unsigned char *buf; /* where to write header */ 93 | int bufSize; 94 | unsigned long* pkeys; 95 | const unsigned long* pcrc_32_tab; 96 | unsigned long crcForCrypting; 97 | { 98 | int n; /* index in random header */ 99 | int t; /* temporary */ 100 | int c; /* random byte */ 101 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ 102 | static unsigned calls = 0; /* ensure different random header each time */ 103 | 104 | if (bufSize> 7) & 0xff; 119 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); 120 | } 121 | /* Encrypt random header (last two bytes is high word of crc) */ 122 | init_keys(passwd, pkeys, pcrc_32_tab); 123 | for (n = 0; n < RAND_HEAD_LEN-2; n++) 124 | { 125 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); 126 | } 127 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); 128 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); 129 | return n; 130 | } 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /Core/Z80_interface.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | Z80_interface.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 25 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added Z80 dma triggering. 34 | 35 | 22 AUG 2002 - neopop_uk 36 | ======================================= 37 | - Added correct DMA chaining behaviour. 38 | 39 | //--------------------------------------------------------------------------- 40 | */ 41 | 42 | #include "neopop.h" 43 | #include "mem.h" 44 | #include "sound.h" 45 | #include "Z80_interface.h" 46 | #include "TLCS900h_registers.h" 47 | #include "interrupt.h" 48 | #include "dma.h" 49 | 50 | //============================================================================= 51 | 52 | int DAsm(char *S,byte *A); 53 | 54 | Z80 Z80_regs; 55 | 56 | //============================================================================= 57 | 58 | _u8 RdZ80(_u16 address) 59 | { 60 | if (address <= 0xFFF) 61 | return ram[0x7000 + address]; 62 | 63 | if (address == 0x8000) 64 | { 65 | #ifdef NEOPOP_DEBUG 66 | if (filter_sound) 67 | system_debug_message("z80 <- TLCS900h: Read ... %02X", ram[0xBC]); 68 | #endif 69 | return ram[0xBC]; 70 | } 71 | 72 | return 0; 73 | } 74 | 75 | //============================================================================= 76 | 77 | void WrZ80(_u16 address, _u8 value) 78 | { 79 | if (address <= 0x0FFF) 80 | { 81 | ram[0x7000 + address] = value; 82 | return; 83 | } 84 | 85 | if (address == 0x8000) 86 | { 87 | #ifdef NEOPOP_DEBUG 88 | if (filter_sound) 89 | system_debug_message("z80 -> TLCS900h: Write ... %02X", value); 90 | #endif 91 | ram[0xBC] = value; 92 | return; 93 | } 94 | 95 | if (address == 0x4001) { Write_SoundChipTone(value); return; } 96 | if (address == 0x4000) { Write_SoundChipNoise(value); return; } 97 | 98 | if (address == 0xC000 && (statusIFF() <= (ram[0x71] & 0x7))) 99 | { 100 | interrupt(6); // Z80 Int. 101 | 102 | if (ram[0x007C] == 0x0C) DMA_update(0); 103 | else { if (ram[0x007D] == 0x0C) DMA_update(1); 104 | else { if (ram[0x007E] == 0x0C) DMA_update(2); 105 | else { if (ram[0x007F] == 0x0C) DMA_update(3); }}} 106 | } 107 | } 108 | 109 | //============================================================================= 110 | 111 | void OutZ80(_u16 port, _u8 value) 112 | { 113 | #ifdef NEOPOP_DEBUG 114 | // if (filter_sound) system_debug_message("Z80: Port out %04X <= %02X", port, value); 115 | #endif 116 | } 117 | 118 | _u8 InZ80(_u16 port) 119 | { 120 | #ifdef NEOPOP_DEBUG 121 | // if (filter_sound) system_debug_message("Z80: Port in %04X", port); 122 | #endif 123 | return 0; 124 | } 125 | 126 | //============================================================================= 127 | 128 | void PatchZ80(register Z80 *R) 129 | { 130 | // Empty 131 | } 132 | 133 | word LoopZ80(register Z80 *R) 134 | { 135 | return INT_QUIT; 136 | } 137 | 138 | //============================================================================= 139 | 140 | void Z80_nmi(void) 141 | { 142 | IntZ80(&Z80_regs, INT_NMI); 143 | } 144 | 145 | void Z80_irq(void) 146 | { 147 | Z80_regs.IFF |= IFF_1; 148 | IntZ80(&Z80_regs, INT_IRQ); 149 | } 150 | 151 | void Z80_reset(void) 152 | { 153 | ResetZ80(&Z80_regs); 154 | Z80_regs.SP.W = 0; 155 | } 156 | 157 | //============================================================================= 158 | 159 | _u16 Z80_getReg(_u8 reg) 160 | { 161 | _u16* r = (_u16*)&Z80_regs; 162 | return r[reg]; 163 | } 164 | 165 | void Z80_setReg(_u8 reg, _u16 value) 166 | { 167 | _u16* r = (_u16*)&Z80_regs; 168 | r[reg] = value; 169 | } 170 | 171 | //============================================================================= 172 | 173 | char* Z80_disassemble(_u16* pc_in) 174 | { 175 | int bcnt, i; 176 | _u16 pc = *pc_in; 177 | char instr[64]; //Print the disassembled instruction to this string 178 | _u8 str[80]; 179 | memset(str, 0, 80); 180 | 181 | //Add the program counter 182 | sprintf(str, " %03X: ", pc); 183 | 184 | //Disassemble instruction 185 | bcnt = DAsm(instr,ram + 0x7000 + pc); 186 | 187 | //Add the instruction 188 | strcat(str, instr); 189 | 190 | //Add the bytes used 191 | for (i = strlen(str); i < 32; i++) 192 | str[i] = ' '; 193 | str[32] = '\"'; 194 | for (i = 0; i < bcnt; i++) 195 | { 196 | _u8 tmp[80]; 197 | sprintf(tmp, "%02X ", *(ram + 0x7000 + pc + i)); 198 | strcat(str, tmp); 199 | } 200 | str[strlen(str) - 1] = '\"'; 201 | 202 | *pc_in = pc + bcnt; 203 | return strdup(str); 204 | } 205 | 206 | //============================================================================= 207 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret_reg.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret_reg.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifndef __TLCS900H_REG__ 35 | #define __TLCS900H_REG__ 36 | //========================================================================= 37 | 38 | //===== LD r,# 39 | void regLDi(void); 40 | 41 | //===== PUSH r 42 | void regPUSH(void); 43 | 44 | //===== POP r 45 | void regPOP(void); 46 | 47 | //===== CPL r 48 | void regCPL(void); 49 | 50 | //===== NEG r 51 | void regNEG(void); 52 | 53 | //===== MUL rr,# 54 | void regMULi(void); 55 | 56 | //===== MULS rr,# 57 | void regMULSi(void); 58 | 59 | //===== DIV rr,# 60 | void regDIVi(void); 61 | 62 | //===== DIVS rr,# 63 | void regDIVSi(void); 64 | 65 | //===== LINK r,dd 66 | void regLINK(void); 67 | 68 | //===== UNLK r 69 | void regUNLK(void); 70 | 71 | //===== BS1F A,r 72 | void regBS1F(void); 73 | 74 | //===== BS1B A,r 75 | void regBS1B(void); 76 | 77 | //===== DAA r 78 | void regDAA(void); 79 | 80 | //===== EXTZ r 81 | void regEXTZ(void); 82 | 83 | //===== EXTS r 84 | void regEXTS(void); 85 | 86 | //===== PAA r 87 | void regPAA(void); 88 | 89 | //===== MIRR r 90 | void regMIRR(void); 91 | 92 | //===== MULA r 93 | void regMULA(void); 94 | 95 | //===== DJNZ r,d 96 | void regDJNZ(void); 97 | 98 | //===== ANDCF #,r 99 | void regANDCFi(void); 100 | 101 | //===== ORCF #,r 102 | void regORCFi(void); 103 | 104 | //===== XORCF #,r 105 | void regXORCFi(void); 106 | 107 | //===== LDCF #,r 108 | void regLDCFi(void); 109 | 110 | //===== STCF #,r 111 | void regSTCFi(void); 112 | 113 | //===== ANDCF A,r 114 | void regANDCFA(void); 115 | 116 | //===== ORCF A,r 117 | void regORCFA(void); 118 | 119 | //===== XORCF A,r 120 | void regXORCFA(void); 121 | 122 | //===== LDCF A,r 123 | void regLDCFA(void); 124 | 125 | //===== STCF A,r 126 | void regSTCFA(void); 127 | 128 | //===== LDC cr,r 129 | void regLDCcrr(void); 130 | 131 | //===== LDC r,cr 132 | void regLDCrcr(void); 133 | 134 | //===== RES #,r 135 | void regRES(void); 136 | 137 | //===== SET #,r 138 | void regSET(void); 139 | 140 | //===== CHG #,r 141 | void regCHG(void); 142 | 143 | //===== BIT #,r 144 | void regBIT(void); 145 | 146 | //===== TSET #,r 147 | void regTSET(void); 148 | 149 | //===== MINC1 #,r 150 | void regMINC1(void); 151 | 152 | //===== MINC2 #,r 153 | void regMINC2(void); 154 | 155 | //===== MINC4 #,r 156 | void regMINC4(void); 157 | 158 | //===== MDEC1 #,r 159 | void regMDEC1(void); 160 | 161 | //===== MDEC2 #,r 162 | void regMDEC2(void); 163 | 164 | //===== MDEC4 #,r 165 | void regMDEC4(void); 166 | 167 | //===== MUL RR,r 168 | void regMUL(void); 169 | 170 | //===== MULS RR,r 171 | void regMULS(void); 172 | 173 | //===== DIV RR,r 174 | void regDIV(void); 175 | 176 | //===== DIVS RR,r 177 | void regDIVS(void); 178 | 179 | //===== INC #3,r 180 | void regINC(void); 181 | 182 | //===== DEC #3,r 183 | void regDEC(void); 184 | 185 | //===== SCC cc,r 186 | void regSCC(void); 187 | 188 | //===== LD R,r 189 | void regLDRr(void); 190 | 191 | //===== LD r,R 192 | void regLDrR(void); 193 | 194 | //===== ADD R,r 195 | void regADD(void); 196 | 197 | //===== ADC R,r 198 | void regADC(void); 199 | 200 | //===== SUB R,r 201 | void regSUB(void); 202 | 203 | //===== SBC R,r 204 | void regSBC(void); 205 | 206 | //===== LD r,#3 207 | void regLDr3(void); 208 | 209 | //===== EX R,r 210 | void regEX(void); 211 | 212 | //===== ADD r,# 213 | void regADDi(void); 214 | 215 | //===== ADC r,# 216 | void regADCi(void); 217 | 218 | //===== SUB r,# 219 | void regSUBi(void); 220 | 221 | //===== SBC r,# 222 | void regSBCi(void); 223 | 224 | //===== CP r,# 225 | void regCPi(void); 226 | 227 | //===== AND r,# 228 | void regANDi(void); 229 | 230 | //===== OR r,# 231 | void regORi(void); 232 | 233 | //===== XOR r,# 234 | void regXORi(void); 235 | 236 | //===== AND R,r 237 | void regAND(void); 238 | 239 | //===== OR R,r 240 | void regOR(void); 241 | 242 | //===== XOR R,r 243 | void regXOR(void); 244 | 245 | //===== CP r,#3 246 | void regCPr3(void); 247 | 248 | //===== CP R,r 249 | void regCP(void); 250 | 251 | //===== RLC #,r 252 | void regRLCi(void); 253 | 254 | //===== RRC #,r 255 | void regRRCi(void); 256 | 257 | //===== RL #,r 258 | void regRLi(void); 259 | 260 | //===== RR #,r 261 | void regRRi(void); 262 | 263 | //===== SLA #,r 264 | void regSLAi(void); 265 | 266 | //===== SRA #,r 267 | void regSRAi(void); 268 | 269 | //===== SLL #,r 270 | void regSLLi(void); 271 | 272 | //===== SRL #,r 273 | void regSRLi(void); 274 | 275 | //===== RLC A,r 276 | void regRLCA(void); 277 | 278 | //===== RRC A,r 279 | void regRRCA(void); 280 | 281 | //===== RL A,r 282 | void regRLA(void); 283 | 284 | //===== RR A,r 285 | void regRRA(void); 286 | 287 | //===== SLA A,r 288 | void regSLAA(void); 289 | 290 | //===== SRA A,r 291 | void regSRAA(void); 292 | 293 | //===== SLL A,r 294 | void regSLLA(void); 295 | 296 | //===== SRL A,r 297 | void regSRLA(void); 298 | 299 | //========================================================================= 300 | #endif 301 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeB0.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeB0.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | ((_u8*)&gprBank[0][0]) + 0,((_u8*)&gprBank[0][0]) + 1, //BANK 0 35 | ((_u8*)&gprBank[0][0]) + 2, ((_u8*)&gprBank[0][0]) + 3, 36 | ((_u8*)&gprBank[0][1]) + 0,((_u8*)&gprBank[0][1]) + 1, 37 | ((_u8*)&gprBank[0][1]) + 2, ((_u8*)&gprBank[0][1]) + 3, 38 | ((_u8*)&gprBank[0][2]) + 0,((_u8*)&gprBank[0][2]) + 1, 39 | ((_u8*)&gprBank[0][2]) + 2, ((_u8*)&gprBank[0][2]) + 3, 40 | ((_u8*)&gprBank[0][3]) + 0,((_u8*)&gprBank[0][3]) + 1, 41 | ((_u8*)&gprBank[0][3]) + 2, ((_u8*)&gprBank[0][3]) + 3, 42 | 43 | ((_u8*)&gprBank[1][0]) + 0,((_u8*)&gprBank[1][0]) + 1, //BANK 1 44 | ((_u8*)&gprBank[1][0]) + 2, ((_u8*)&gprBank[1][0]) + 3, 45 | ((_u8*)&gprBank[1][1]) + 0,((_u8*)&gprBank[1][1]) + 1, 46 | ((_u8*)&gprBank[1][1]) + 2, ((_u8*)&gprBank[1][1]) + 3, 47 | ((_u8*)&gprBank[1][2]) + 0,((_u8*)&gprBank[1][2]) + 1, 48 | ((_u8*)&gprBank[1][2]) + 2, ((_u8*)&gprBank[1][2]) + 3, 49 | ((_u8*)&gprBank[1][3]) + 0,((_u8*)&gprBank[1][3]) + 1, 50 | ((_u8*)&gprBank[1][3]) + 2, ((_u8*)&gprBank[1][3]) + 3, 51 | 52 | ((_u8*)&gprBank[2][0]) + 0,((_u8*)&gprBank[2][0]) + 1, //BANK 2 53 | ((_u8*)&gprBank[2][0]) + 2, ((_u8*)&gprBank[2][0]) + 3, 54 | ((_u8*)&gprBank[2][1]) + 0,((_u8*)&gprBank[2][1]) + 1, 55 | ((_u8*)&gprBank[2][1]) + 2, ((_u8*)&gprBank[2][1]) + 3, 56 | ((_u8*)&gprBank[2][2]) + 0,((_u8*)&gprBank[2][2]) + 1, 57 | ((_u8*)&gprBank[2][2]) + 2, ((_u8*)&gprBank[2][2]) + 3, 58 | ((_u8*)&gprBank[2][3]) + 0,((_u8*)&gprBank[2][3]) + 1, 59 | ((_u8*)&gprBank[2][3]) + 2, ((_u8*)&gprBank[2][3]) + 3, 60 | 61 | ((_u8*)&gprBank[3][0]) + 0,((_u8*)&gprBank[3][0]) + 1, //BANK 3 62 | ((_u8*)&gprBank[3][0]) + 2, ((_u8*)&gprBank[3][0]) + 3, 63 | ((_u8*)&gprBank[3][1]) + 0,((_u8*)&gprBank[3][1]) + 1, 64 | ((_u8*)&gprBank[3][1]) + 2, ((_u8*)&gprBank[3][1]) + 3, 65 | ((_u8*)&gprBank[3][2]) + 0,((_u8*)&gprBank[3][2]) + 1, 66 | ((_u8*)&gprBank[3][2]) + 2, ((_u8*)&gprBank[3][2]) + 3, 67 | ((_u8*)&gprBank[3][3]) + 0,((_u8*)&gprBank[3][3]) + 1, 68 | ((_u8*)&gprBank[3][3]) + 2, ((_u8*)&gprBank[3][3]) + 3, 69 | 70 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 71 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 72 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 73 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 74 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 75 | 76 | //Previous Bank 77 | (_u8*)&rErr,(_u8*)&rErr, 78 | (_u8*)&rErr,(_u8*)&rErr, 79 | (_u8*)&rErr,(_u8*)&rErr, 80 | (_u8*)&rErr,(_u8*)&rErr, 81 | (_u8*)&rErr,(_u8*)&rErr, 82 | (_u8*)&rErr,(_u8*)&rErr, 83 | (_u8*)&rErr,(_u8*)&rErr, 84 | (_u8*)&rErr,(_u8*)&rErr, 85 | 86 | //Current Bank 87 | ((_u8*)&gprBank[0][0]) + 0,((_u8*)&gprBank[0][0]) + 1, 88 | ((_u8*)&gprBank[0][0]) + 2, ((_u8*)&gprBank[0][0]) + 3, 89 | ((_u8*)&gprBank[0][1]) + 0,((_u8*)&gprBank[0][1]) + 1, 90 | ((_u8*)&gprBank[0][1]) + 2, ((_u8*)&gprBank[0][1]) + 3, 91 | ((_u8*)&gprBank[0][2]) + 0,((_u8*)&gprBank[0][2]) + 1, 92 | ((_u8*)&gprBank[0][2]) + 2, ((_u8*)&gprBank[0][2]) + 3, 93 | ((_u8*)&gprBank[0][3]) + 0,((_u8*)&gprBank[0][3]) + 1, 94 | ((_u8*)&gprBank[0][3]) + 2, ((_u8*)&gprBank[0][3]) + 3, 95 | 96 | ((_u8*)&gpr[0]) + 0, ((_u8*)&gpr[0]) + 1, 97 | ((_u8*)&gpr[0]) + 2, ((_u8*)&gpr[0]) + 3, 98 | ((_u8*)&gpr[1]) + 0, ((_u8*)&gpr[1]) + 1, 99 | ((_u8*)&gpr[1]) + 2, ((_u8*)&gpr[1]) + 3, 100 | ((_u8*)&gpr[2]) + 0, ((_u8*)&gpr[2]) + 1, 101 | ((_u8*)&gpr[2]) + 2, ((_u8*)&gpr[2]) + 3, 102 | ((_u8*)&gpr[3]) + 0, ((_u8*)&gpr[3]) + 1, 103 | ((_u8*)&gpr[3]) + 2, ((_u8*)&gpr[3]) + 3 104 | 105 | //============================================================================= 106 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeB1.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeB1.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | ((_u8*)&gprBank[0][0]) + 0,((_u8*)&gprBank[0][0]) + 1, //BANK 0 35 | ((_u8*)&gprBank[0][0]) + 2, ((_u8*)&gprBank[0][0]) + 3, 36 | ((_u8*)&gprBank[0][1]) + 0,((_u8*)&gprBank[0][1]) + 1, 37 | ((_u8*)&gprBank[0][1]) + 2, ((_u8*)&gprBank[0][1]) + 3, 38 | ((_u8*)&gprBank[0][2]) + 0,((_u8*)&gprBank[0][2]) + 1, 39 | ((_u8*)&gprBank[0][2]) + 2, ((_u8*)&gprBank[0][2]) + 3, 40 | ((_u8*)&gprBank[0][3]) + 0,((_u8*)&gprBank[0][3]) + 1, 41 | ((_u8*)&gprBank[0][3]) + 2, ((_u8*)&gprBank[0][3]) + 3, 42 | 43 | ((_u8*)&gprBank[1][0]) + 0,((_u8*)&gprBank[1][0]) + 1, //BANK 1 44 | ((_u8*)&gprBank[1][0]) + 2, ((_u8*)&gprBank[1][0]) + 3, 45 | ((_u8*)&gprBank[1][1]) + 0,((_u8*)&gprBank[1][1]) + 1, 46 | ((_u8*)&gprBank[1][1]) + 2, ((_u8*)&gprBank[1][1]) + 3, 47 | ((_u8*)&gprBank[1][2]) + 0,((_u8*)&gprBank[1][2]) + 1, 48 | ((_u8*)&gprBank[1][2]) + 2, ((_u8*)&gprBank[1][2]) + 3, 49 | ((_u8*)&gprBank[1][3]) + 0,((_u8*)&gprBank[1][3]) + 1, 50 | ((_u8*)&gprBank[1][3]) + 2, ((_u8*)&gprBank[1][3]) + 3, 51 | 52 | ((_u8*)&gprBank[2][0]) + 0,((_u8*)&gprBank[2][0]) + 1, //BANK 2 53 | ((_u8*)&gprBank[2][0]) + 2, ((_u8*)&gprBank[2][0]) + 3, 54 | ((_u8*)&gprBank[2][1]) + 0,((_u8*)&gprBank[2][1]) + 1, 55 | ((_u8*)&gprBank[2][1]) + 2, ((_u8*)&gprBank[2][1]) + 3, 56 | ((_u8*)&gprBank[2][2]) + 0,((_u8*)&gprBank[2][2]) + 1, 57 | ((_u8*)&gprBank[2][2]) + 2, ((_u8*)&gprBank[2][2]) + 3, 58 | ((_u8*)&gprBank[2][3]) + 0,((_u8*)&gprBank[2][3]) + 1, 59 | ((_u8*)&gprBank[2][3]) + 2, ((_u8*)&gprBank[2][3]) + 3, 60 | 61 | ((_u8*)&gprBank[3][0]) + 0,((_u8*)&gprBank[3][0]) + 1, //BANK 3 62 | ((_u8*)&gprBank[3][0]) + 2, ((_u8*)&gprBank[3][0]) + 3, 63 | ((_u8*)&gprBank[3][1]) + 0,((_u8*)&gprBank[3][1]) + 1, 64 | ((_u8*)&gprBank[3][1]) + 2, ((_u8*)&gprBank[3][1]) + 3, 65 | ((_u8*)&gprBank[3][2]) + 0,((_u8*)&gprBank[3][2]) + 1, 66 | ((_u8*)&gprBank[3][2]) + 2, ((_u8*)&gprBank[3][2]) + 3, 67 | ((_u8*)&gprBank[3][3]) + 0,((_u8*)&gprBank[3][3]) + 1, 68 | ((_u8*)&gprBank[3][3]) + 2, ((_u8*)&gprBank[3][3]) + 3, 69 | 70 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 71 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 72 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 73 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 74 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 75 | 76 | //Previous Bank 77 | ((_u8*)&gprBank[0][0]) + 0,((_u8*)&gprBank[0][0]) + 1, 78 | ((_u8*)&gprBank[0][0]) + 2, ((_u8*)&gprBank[0][0]) + 3, 79 | ((_u8*)&gprBank[0][1]) + 0,((_u8*)&gprBank[0][1]) + 1, 80 | ((_u8*)&gprBank[0][1]) + 2, ((_u8*)&gprBank[0][1]) + 3, 81 | ((_u8*)&gprBank[0][2]) + 0,((_u8*)&gprBank[0][2]) + 1, 82 | ((_u8*)&gprBank[0][2]) + 2, ((_u8*)&gprBank[0][2]) + 3, 83 | ((_u8*)&gprBank[0][3]) + 0,((_u8*)&gprBank[0][3]) + 1, 84 | ((_u8*)&gprBank[0][3]) + 2, ((_u8*)&gprBank[0][3]) + 3, 85 | 86 | //Current Bank 87 | ((_u8*)&gprBank[1][0]) + 0,((_u8*)&gprBank[1][0]) + 1, 88 | ((_u8*)&gprBank[1][0]) + 2, ((_u8*)&gprBank[1][0]) + 3, 89 | ((_u8*)&gprBank[1][1]) + 0,((_u8*)&gprBank[1][1]) + 1, 90 | ((_u8*)&gprBank[1][1]) + 2, ((_u8*)&gprBank[1][1]) + 3, 91 | ((_u8*)&gprBank[1][2]) + 0,((_u8*)&gprBank[1][2]) + 1, 92 | ((_u8*)&gprBank[1][2]) + 2, ((_u8*)&gprBank[1][2]) + 3, 93 | ((_u8*)&gprBank[1][3]) + 0,((_u8*)&gprBank[1][3]) + 1, 94 | ((_u8*)&gprBank[1][3]) + 2, ((_u8*)&gprBank[1][3]) + 3, 95 | 96 | ((_u8*)&gpr[0]) + 0, ((_u8*)&gpr[0]) + 1, 97 | ((_u8*)&gpr[0]) + 2, ((_u8*)&gpr[0]) + 3, 98 | ((_u8*)&gpr[1]) + 0, ((_u8*)&gpr[1]) + 1, 99 | ((_u8*)&gpr[1]) + 2, ((_u8*)&gpr[1]) + 3, 100 | ((_u8*)&gpr[2]) + 0, ((_u8*)&gpr[2]) + 1, 101 | ((_u8*)&gpr[2]) + 2, ((_u8*)&gpr[2]) + 3, 102 | ((_u8*)&gpr[3]) + 0, ((_u8*)&gpr[3]) + 1, 103 | ((_u8*)&gpr[3]) + 2, ((_u8*)&gpr[3]) + 3 104 | 105 | //============================================================================= 106 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeB2.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeB2.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | ((_u8*)&gprBank[0][0]) + 0,((_u8*)&gprBank[0][0]) + 1, //BANK 0 35 | ((_u8*)&gprBank[0][0]) + 2, ((_u8*)&gprBank[0][0]) + 3, 36 | ((_u8*)&gprBank[0][1]) + 0,((_u8*)&gprBank[0][1]) + 1, 37 | ((_u8*)&gprBank[0][1]) + 2, ((_u8*)&gprBank[0][1]) + 3, 38 | ((_u8*)&gprBank[0][2]) + 0,((_u8*)&gprBank[0][2]) + 1, 39 | ((_u8*)&gprBank[0][2]) + 2, ((_u8*)&gprBank[0][2]) + 3, 40 | ((_u8*)&gprBank[0][3]) + 0,((_u8*)&gprBank[0][3]) + 1, 41 | ((_u8*)&gprBank[0][3]) + 2, ((_u8*)&gprBank[0][3]) + 3, 42 | 43 | ((_u8*)&gprBank[1][0]) + 0,((_u8*)&gprBank[1][0]) + 1, //BANK 1 44 | ((_u8*)&gprBank[1][0]) + 2, ((_u8*)&gprBank[1][0]) + 3, 45 | ((_u8*)&gprBank[1][1]) + 0,((_u8*)&gprBank[1][1]) + 1, 46 | ((_u8*)&gprBank[1][1]) + 2, ((_u8*)&gprBank[1][1]) + 3, 47 | ((_u8*)&gprBank[1][2]) + 0,((_u8*)&gprBank[1][2]) + 1, 48 | ((_u8*)&gprBank[1][2]) + 2, ((_u8*)&gprBank[1][2]) + 3, 49 | ((_u8*)&gprBank[1][3]) + 0,((_u8*)&gprBank[1][3]) + 1, 50 | ((_u8*)&gprBank[1][3]) + 2, ((_u8*)&gprBank[1][3]) + 3, 51 | 52 | ((_u8*)&gprBank[2][0]) + 0,((_u8*)&gprBank[2][0]) + 1, //BANK 2 53 | ((_u8*)&gprBank[2][0]) + 2, ((_u8*)&gprBank[2][0]) + 3, 54 | ((_u8*)&gprBank[2][1]) + 0,((_u8*)&gprBank[2][1]) + 1, 55 | ((_u8*)&gprBank[2][1]) + 2, ((_u8*)&gprBank[2][1]) + 3, 56 | ((_u8*)&gprBank[2][2]) + 0,((_u8*)&gprBank[2][2]) + 1, 57 | ((_u8*)&gprBank[2][2]) + 2, ((_u8*)&gprBank[2][2]) + 3, 58 | ((_u8*)&gprBank[2][3]) + 0,((_u8*)&gprBank[2][3]) + 1, 59 | ((_u8*)&gprBank[2][3]) + 2, ((_u8*)&gprBank[2][3]) + 3, 60 | 61 | ((_u8*)&gprBank[3][0]) + 0,((_u8*)&gprBank[3][0]) + 1, //BANK 3 62 | ((_u8*)&gprBank[3][0]) + 2, ((_u8*)&gprBank[3][0]) + 3, 63 | ((_u8*)&gprBank[3][1]) + 0,((_u8*)&gprBank[3][1]) + 1, 64 | ((_u8*)&gprBank[3][1]) + 2, ((_u8*)&gprBank[3][1]) + 3, 65 | ((_u8*)&gprBank[3][2]) + 0,((_u8*)&gprBank[3][2]) + 1, 66 | ((_u8*)&gprBank[3][2]) + 2, ((_u8*)&gprBank[3][2]) + 3, 67 | ((_u8*)&gprBank[3][3]) + 0,((_u8*)&gprBank[3][3]) + 1, 68 | ((_u8*)&gprBank[3][3]) + 2, ((_u8*)&gprBank[3][3]) + 3, 69 | 70 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 71 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 72 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 73 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 74 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 75 | 76 | //Previous Bank 77 | ((_u8*)&gprBank[1][0]) + 0,((_u8*)&gprBank[1][0]) + 1, 78 | ((_u8*)&gprBank[1][0]) + 2, ((_u8*)&gprBank[1][0]) + 3, 79 | ((_u8*)&gprBank[1][1]) + 0,((_u8*)&gprBank[1][1]) + 1, 80 | ((_u8*)&gprBank[1][1]) + 2, ((_u8*)&gprBank[1][1]) + 3, 81 | ((_u8*)&gprBank[1][2]) + 0,((_u8*)&gprBank[1][2]) + 1, 82 | ((_u8*)&gprBank[1][2]) + 2, ((_u8*)&gprBank[1][2]) + 3, 83 | ((_u8*)&gprBank[1][3]) + 0,((_u8*)&gprBank[1][3]) + 1, 84 | ((_u8*)&gprBank[1][3]) + 2, ((_u8*)&gprBank[1][3]) + 3, 85 | 86 | //Current Bank 87 | ((_u8*)&gprBank[2][0]) + 0,((_u8*)&gprBank[2][0]) + 1, 88 | ((_u8*)&gprBank[2][0]) + 2, ((_u8*)&gprBank[2][0]) + 3, 89 | ((_u8*)&gprBank[2][1]) + 0,((_u8*)&gprBank[2][1]) + 1, 90 | ((_u8*)&gprBank[2][1]) + 2, ((_u8*)&gprBank[2][1]) + 3, 91 | ((_u8*)&gprBank[2][2]) + 0,((_u8*)&gprBank[2][2]) + 1, 92 | ((_u8*)&gprBank[2][2]) + 2, ((_u8*)&gprBank[2][2]) + 3, 93 | ((_u8*)&gprBank[2][3]) + 0,((_u8*)&gprBank[2][3]) + 1, 94 | ((_u8*)&gprBank[2][3]) + 2, ((_u8*)&gprBank[2][3]) + 3, 95 | 96 | ((_u8*)&gpr[0]) + 0, ((_u8*)&gpr[0]) + 1, 97 | ((_u8*)&gpr[0]) + 2, ((_u8*)&gpr[0]) + 3, 98 | ((_u8*)&gpr[1]) + 0, ((_u8*)&gpr[1]) + 1, 99 | ((_u8*)&gpr[1]) + 2, ((_u8*)&gpr[1]) + 3, 100 | ((_u8*)&gpr[2]) + 0, ((_u8*)&gpr[2]) + 1, 101 | ((_u8*)&gpr[2]) + 2, ((_u8*)&gpr[2]) + 3, 102 | ((_u8*)&gpr[3]) + 0, ((_u8*)&gpr[3]) + 1, 103 | ((_u8*)&gpr[3]) + 2, ((_u8*)&gpr[3]) + 3 104 | 105 | //============================================================================= 106 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_registers_mapCodeB3.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_registers_mapCodeB3.h 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | ((_u8*)&gprBank[0][0]) + 0,((_u8*)&gprBank[0][0]) + 1, //BANK 0 35 | ((_u8*)&gprBank[0][0]) + 2, ((_u8*)&gprBank[0][0]) + 3, 36 | ((_u8*)&gprBank[0][1]) + 0,((_u8*)&gprBank[0][1]) + 1, 37 | ((_u8*)&gprBank[0][1]) + 2, ((_u8*)&gprBank[0][1]) + 3, 38 | ((_u8*)&gprBank[0][2]) + 0,((_u8*)&gprBank[0][2]) + 1, 39 | ((_u8*)&gprBank[0][2]) + 2, ((_u8*)&gprBank[0][2]) + 3, 40 | ((_u8*)&gprBank[0][3]) + 0,((_u8*)&gprBank[0][3]) + 1, 41 | ((_u8*)&gprBank[0][3]) + 2, ((_u8*)&gprBank[0][3]) + 3, 42 | 43 | ((_u8*)&gprBank[1][0]) + 0,((_u8*)&gprBank[1][0]) + 1, //BANK 1 44 | ((_u8*)&gprBank[1][0]) + 2, ((_u8*)&gprBank[1][0]) + 3, 45 | ((_u8*)&gprBank[1][1]) + 0,((_u8*)&gprBank[1][1]) + 1, 46 | ((_u8*)&gprBank[1][1]) + 2, ((_u8*)&gprBank[1][1]) + 3, 47 | ((_u8*)&gprBank[1][2]) + 0,((_u8*)&gprBank[1][2]) + 1, 48 | ((_u8*)&gprBank[1][2]) + 2, ((_u8*)&gprBank[1][2]) + 3, 49 | ((_u8*)&gprBank[1][3]) + 0,((_u8*)&gprBank[1][3]) + 1, 50 | ((_u8*)&gprBank[1][3]) + 2, ((_u8*)&gprBank[1][3]) + 3, 51 | 52 | ((_u8*)&gprBank[2][0]) + 0,((_u8*)&gprBank[2][0]) + 1, //BANK 2 53 | ((_u8*)&gprBank[2][0]) + 2, ((_u8*)&gprBank[2][0]) + 3, 54 | ((_u8*)&gprBank[2][1]) + 0,((_u8*)&gprBank[2][1]) + 1, 55 | ((_u8*)&gprBank[2][1]) + 2, ((_u8*)&gprBank[2][1]) + 3, 56 | ((_u8*)&gprBank[2][2]) + 0,((_u8*)&gprBank[2][2]) + 1, 57 | ((_u8*)&gprBank[2][2]) + 2, ((_u8*)&gprBank[2][2]) + 3, 58 | ((_u8*)&gprBank[2][3]) + 0,((_u8*)&gprBank[2][3]) + 1, 59 | ((_u8*)&gprBank[2][3]) + 2, ((_u8*)&gprBank[2][3]) + 3, 60 | 61 | ((_u8*)&gprBank[3][0]) + 0,((_u8*)&gprBank[3][0]) + 1, //BANK 3 62 | ((_u8*)&gprBank[3][0]) + 2, ((_u8*)&gprBank[3][0]) + 3, 63 | ((_u8*)&gprBank[3][1]) + 0,((_u8*)&gprBank[3][1]) + 1, 64 | ((_u8*)&gprBank[3][1]) + 2, ((_u8*)&gprBank[3][1]) + 3, 65 | ((_u8*)&gprBank[3][2]) + 0,((_u8*)&gprBank[3][2]) + 1, 66 | ((_u8*)&gprBank[3][2]) + 2, ((_u8*)&gprBank[3][2]) + 3, 67 | ((_u8*)&gprBank[3][3]) + 0,((_u8*)&gprBank[3][3]) + 1, 68 | ((_u8*)&gprBank[3][3]) + 2, ((_u8*)&gprBank[3][3]) + 3, 69 | 70 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 71 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 72 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 73 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 74 | (_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr,(_u8*)&rErr, 75 | 76 | //Previous Bank 77 | ((_u8*)&gprBank[2][0]) + 0,((_u8*)&gprBank[2][0]) + 1, 78 | ((_u8*)&gprBank[2][0]) + 2, ((_u8*)&gprBank[2][0]) + 3, 79 | ((_u8*)&gprBank[2][1]) + 0,((_u8*)&gprBank[2][1]) + 1, 80 | ((_u8*)&gprBank[2][1]) + 2, ((_u8*)&gprBank[2][1]) + 3, 81 | ((_u8*)&gprBank[2][2]) + 0,((_u8*)&gprBank[2][2]) + 1, 82 | ((_u8*)&gprBank[2][2]) + 2, ((_u8*)&gprBank[2][2]) + 3, 83 | ((_u8*)&gprBank[2][3]) + 0,((_u8*)&gprBank[2][3]) + 1, 84 | ((_u8*)&gprBank[2][3]) + 2, ((_u8*)&gprBank[2][3]) + 3, 85 | 86 | //Current Bank 87 | ((_u8*)&gprBank[3][0]) + 0,((_u8*)&gprBank[3][0]) + 1, 88 | ((_u8*)&gprBank[3][0]) + 2, ((_u8*)&gprBank[3][0]) + 3, 89 | ((_u8*)&gprBank[3][1]) + 0,((_u8*)&gprBank[3][1]) + 1, 90 | ((_u8*)&gprBank[3][1]) + 2, ((_u8*)&gprBank[3][1]) + 3, 91 | ((_u8*)&gprBank[3][2]) + 0,((_u8*)&gprBank[3][2]) + 1, 92 | ((_u8*)&gprBank[3][2]) + 2, ((_u8*)&gprBank[3][2]) + 3, 93 | ((_u8*)&gprBank[3][3]) + 0,((_u8*)&gprBank[3][3]) + 1, 94 | ((_u8*)&gprBank[3][3]) + 2, ((_u8*)&gprBank[3][3]) + 3, 95 | 96 | ((_u8*)&gpr[0]) + 0, ((_u8*)&gpr[0]) + 1, 97 | ((_u8*)&gpr[0]) + 2, ((_u8*)&gpr[0]) + 3, 98 | ((_u8*)&gpr[1]) + 0, ((_u8*)&gpr[1]) + 1, 99 | ((_u8*)&gpr[1]) + 2, ((_u8*)&gpr[1]) + 3, 100 | ((_u8*)&gpr[2]) + 0, ((_u8*)&gpr[2]) + 1, 101 | ((_u8*)&gpr[2]) + 2, ((_u8*)&gpr[2]) + 3, 102 | ((_u8*)&gpr[3]) + 0, ((_u8*)&gpr[3]) + 1, 103 | ((_u8*)&gpr[3]) + 2, ((_u8*)&gpr[3]) + 3 104 | 105 | //============================================================================= 106 | -------------------------------------------------------------------------------- /Core/state.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | state.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 14 SEP 2007 - Akop Karapetyan 28 | ======================================= 29 | - state_store and state_restore now return true/false 30 | 31 | 20 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Cleaned and tidied up for the source release 34 | 35 | 28 JUL 2002 - neopop_uk 36 | ======================================= 37 | - Converted the load and save functions to use the new state name. 38 | - Move the version "0050" state loader into it's own function, this makes 39 | it much easier to add new loaders in the future. 40 | 41 | 15 AUG 2002 - neopop_uk 42 | ======================================= 43 | - Removed storing the 'halt' state as the variable no longer exists. 44 | - Changed 'int reserved1' into 'BOOL eepromStatusEnable' 45 | 46 | //--------------------------------------------------------------------------- 47 | */ 48 | 49 | #include "neopop.h" 50 | #include "state.h" 51 | #include "TLCS900h_registers.h" 52 | #include "interrupt.h" 53 | #include "dma.h" 54 | #include "mem.h" 55 | 56 | //============================================================================= 57 | 58 | static void read_state_0050(char* filename); 59 | 60 | //----------------------------------------------------------------------------- 61 | // state_restore() 62 | //----------------------------------------------------------------------------- 63 | BOOL state_restore(char* filename) 64 | { 65 | _u16 version; 66 | 67 | if (system_io_state_read(filename, (_u8*)&version, sizeof(_u16))) 68 | { 69 | switch(version) 70 | { 71 | case 0x0050: read_state_0050(filename); break; 72 | 73 | default: 74 | system_message(system_get_string(IDS_BADSTATE)); 75 | return FALSE; 76 | } 77 | 78 | #ifdef NEOPOP_DEBUG 79 | system_debug_message("Restoring State ..."); 80 | system_debug_refresh(); 81 | #endif 82 | 83 | return TRUE; 84 | } 85 | 86 | return FALSE; 87 | } 88 | 89 | //============================================================================= 90 | 91 | //----------------------------------------------------------------------------- 92 | // state_store() 93 | //----------------------------------------------------------------------------- 94 | BOOL state_store(char* filename) 95 | { 96 | NEOPOPSTATE0050 state; 97 | int i,j; 98 | 99 | //Build a state description 100 | state.valid_state_id = 0x0050; 101 | memcpy(&state.header, rom_header, sizeof(RomHeader)); 102 | 103 | state.eepromStatusEnable = eepromStatusEnable; 104 | 105 | //TLCS-900h Registers 106 | state.pc = pc; 107 | state.sr = sr; 108 | state.f_dash = f_dash; 109 | 110 | for (i = 0; i < 4; i++) 111 | { 112 | state.gpr[i] = gpr[i]; 113 | for (j = 0; j < 4; j++) 114 | state.gprBank[i][j] = gprBank[i][j]; 115 | } 116 | 117 | //Z80 Registers 118 | memcpy(&state.Z80_regs, &Z80_regs, sizeof(Z80)); 119 | 120 | //Sound Chips 121 | memcpy(&state.toneChip, &toneChip, sizeof(SoundChip)); 122 | memcpy(&state.noiseChip, &noiseChip, sizeof(SoundChip)); 123 | 124 | //Memory 125 | memcpy(&state.ram, ram, 0xC000); 126 | 127 | //Timers 128 | state.timer_hint = timer_hint; 129 | 130 | for (i = 0; i < 4; i++) //Up-counters 131 | state.timer[i] = timer[i]; 132 | 133 | state.timer_clock0 = timer_clock0; 134 | state.timer_clock1 = timer_clock1; 135 | state.timer_clock2 = timer_clock2; 136 | state.timer_clock3 = timer_clock3; 137 | 138 | //DMA 139 | for (i = 0; i < 4; i++) 140 | { 141 | state.dmaS[i] = dmaS[i]; 142 | state.dmaD[i] = dmaD[i]; 143 | state.dmaC[i] = dmaC[i]; 144 | state.dmaM[i] = dmaM[i]; 145 | } 146 | 147 | #ifdef NEOPOP_DEBUG 148 | system_debug_message("Saving State ..."); 149 | #endif 150 | 151 | return system_io_state_write(filename, (_u8*)&state, sizeof(NEOPOPSTATE0050)); 152 | } 153 | 154 | //============================================================================= 155 | 156 | static void read_state_0050(char* filename) 157 | { 158 | NEOPOPSTATE0050 state; 159 | int i,j; 160 | 161 | if (system_io_state_read(filename, (_u8*)&state, sizeof(NEOPOPSTATE0050))) 162 | { 163 | //Verify correct rom... 164 | if (memcmp(rom_header, &state.header, sizeof(RomHeader)) != 0) 165 | { 166 | system_message(system_get_string(IDS_WRONGROM)); 167 | return; 168 | } 169 | 170 | //Apply state description 171 | reset(); 172 | 173 | eepromStatusEnable = state.eepromStatusEnable; 174 | 175 | //TLCS-900h Registers 176 | pc = state.pc; 177 | sr = state.sr; changedSP(); 178 | f_dash = state.f_dash; 179 | 180 | eepromStatusEnable = state.eepromStatusEnable; 181 | 182 | for (i = 0; i < 4; i++) 183 | { 184 | gpr[i] = state.gpr[i]; 185 | for (j = 0; j < 4; j++) 186 | gprBank[i][j] = state.gprBank[i][j]; 187 | } 188 | 189 | //Timers 190 | timer_hint = state.timer_hint; 191 | 192 | for (i = 0; i < 4; i++) //Up-counters 193 | timer[i] = state.timer[i]; 194 | 195 | timer_clock0 = state.timer_clock0; 196 | timer_clock1 = state.timer_clock1; 197 | timer_clock2 = state.timer_clock2; 198 | timer_clock3 = state.timer_clock3; 199 | 200 | //Z80 Registers 201 | memcpy(&Z80_regs, &state.Z80_regs, sizeof(Z80)); 202 | 203 | //Sound Chips 204 | memcpy(&toneChip, &state.toneChip, sizeof(SoundChip)); 205 | memcpy(&noiseChip, &state.noiseChip, sizeof(SoundChip)); 206 | 207 | //DMA 208 | for (i = 0; i < 4; i++) 209 | { 210 | dmaS[i] = state.dmaS[i]; 211 | dmaD[i] = state.dmaD[i]; 212 | dmaC[i] = state.dmaC[i]; 213 | dmaM[i] = state.dmaM[i]; 214 | } 215 | 216 | //Memory 217 | memcpy(ram, &state.ram, 0xC000); 218 | } 219 | } 220 | 221 | //============================================================================= 222 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_disassemble_dst.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_disassemble_dst.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | //--------------------------------------------------------------------------- 32 | */ 33 | 34 | #ifdef NEOPOP_DEBUG 35 | //========================================================================= 36 | 37 | #include "neopop.h" 38 | #include "TLCS900h_disassemble.h" 39 | #include "TLCS900h_registers.h" 40 | #include "TLCS900h_interpret.h" 41 | 42 | //========================================================================= 43 | 44 | static void LDBi() 45 | { 46 | sprintf(instr, "LD (%s),0x%02X", extra, get8_dis()); 47 | } 48 | 49 | static void LDWi() 50 | { 51 | sprintf(instr, "LD (%s),0x%04X", extra, get16_dis()); 52 | } 53 | 54 | static void POPB() 55 | { 56 | sprintf(instr, "POP.b (%s)", extra); 57 | } 58 | 59 | static void POPW() 60 | { 61 | sprintf(instr, "POP.w (%s)", extra); 62 | } 63 | 64 | static void LDBm16() 65 | { 66 | sprintf(instr, "LD.b (%s),(0x%04X)", extra, get16_dis()); 67 | } 68 | 69 | static void LDWm16() 70 | { 71 | sprintf(instr, "LD.w (%s),(0x%04X)", extra, get16_dis()); 72 | } 73 | 74 | static void LDAW() 75 | { 76 | sprintf(instr, "LDA %s,%s", gprName[second & 7][1], extra); 77 | } 78 | 79 | static void LDAL() 80 | { 81 | sprintf(instr, "LDA %s,%s", gprName[second & 7][2], extra); 82 | } 83 | 84 | static void ANDCFA() 85 | { 86 | sprintf(instr, "ANDCF A,(%s)", extra); 87 | } 88 | 89 | static void ORCFA() 90 | { 91 | sprintf(instr, "ORCF A,(%s)", extra); 92 | } 93 | 94 | static void XORCFA() 95 | { 96 | sprintf(instr, "XORCF A,(%s)", extra); 97 | } 98 | 99 | static void LDCFA() 100 | { 101 | sprintf(instr, "LDCF A,(%s)", extra); 102 | } 103 | 104 | static void STCFA() 105 | { 106 | sprintf(instr, "STCF A,(%s)", extra); 107 | } 108 | 109 | static void LDBR() 110 | { 111 | sprintf(instr, "LD (%s),%s", extra, gprName[second&7][0]); 112 | } 113 | 114 | static void LDWR() 115 | { 116 | sprintf(instr, "LD (%s),%s", extra, gprName[second&7][1]); 117 | } 118 | 119 | static void LDLR() 120 | { 121 | sprintf(instr, "LD (%s),%s", extra, gprName[second&7][2]); 122 | } 123 | 124 | static void ANDCF() 125 | { 126 | sprintf(instr, "ANDCF %d,(%s)", second & 7, extra); 127 | } 128 | 129 | static void ORCF() 130 | { 131 | sprintf(instr, "ORCF %d,(%s)", second & 7, extra); 132 | } 133 | 134 | static void XORCF() 135 | { 136 | sprintf(instr, "XORCF %d,(%s)", second & 7, extra); 137 | } 138 | 139 | static void LDCF() 140 | { 141 | sprintf(instr, "LDCF %d,(%s)", second & 7, extra); 142 | } 143 | 144 | static void STCF() 145 | { 146 | sprintf(instr, "STCF %d,(%s)", second & 7, extra); 147 | } 148 | 149 | static void TSET() 150 | { 151 | sprintf(instr, "TSET %d,(%s)", second & 7, extra); 152 | } 153 | 154 | static void RES() 155 | { 156 | sprintf(instr, "RES %d,(%s)", second & 7, extra); 157 | } 158 | 159 | static void SET() 160 | { 161 | sprintf(instr, "SET %d,(%s)", second & 7, extra); 162 | } 163 | 164 | static void CHG() 165 | { 166 | sprintf(instr, "CHG %d,(%s)", second & 7, extra); 167 | } 168 | 169 | static void BIT() 170 | { 171 | sprintf(instr, "BIT %d,(%s)", second & 7, extra); 172 | } 173 | 174 | static void JP() 175 | { 176 | sprintf(instr, "JP %s,%s", ccName[second & 0xF], extra); 177 | } 178 | 179 | static void CALL() 180 | { 181 | sprintf(instr, "CALL %s,%s", ccName[second & 0xF], extra); 182 | } 183 | 184 | static void RET() 185 | { 186 | sprintf(instr, "RET %s", ccName[second & 0xF]); 187 | } 188 | 189 | //========================================================================= 190 | 191 | //Secondary (DST) Instruction decode 192 | static void (*decode[256])() = 193 | { 194 | /*0*/ LDBi, 0, LDWi, 0, POPB, 0, POPW, 0, 195 | 0, 0, 0, 0, 0, 0, 0, 0, 196 | /*1*/ 0, 0, 0, 0, LDBm16, 0, LDWm16, 0, 197 | 0, 0, 0, 0, 0, 0, 0, 0, 198 | /*2*/ LDAW, LDAW, LDAW, LDAW, LDAW, LDAW, LDAW, LDAW, 199 | ANDCFA, ORCFA, XORCFA, LDCFA, STCFA, 0, 0, 0, 200 | /*3*/ LDAL, LDAL, LDAL, LDAL, LDAL, LDAL, LDAL, LDAL, 201 | 0, 0, 0, 0, 0, 0, 0, 0, 202 | /*4*/ LDBR, LDBR, LDBR, LDBR, LDBR, LDBR, LDBR, LDBR, 203 | 0, 0, 0, 0, 0, 0, 0, 0, 204 | /*5*/ LDWR, LDWR, LDWR, LDWR, LDWR, LDWR, LDWR, LDWR, 205 | 0, 0, 0, 0, 0, 0, 0, 0, 206 | /*6*/ LDLR, LDLR, LDLR, LDLR, LDLR, LDLR, LDLR, LDLR, 207 | 0, 0, 0, 0, 0, 0, 0, 0, 208 | /*7*/ 0, 0, 0, 0, 0, 0, 0, 0, 209 | 0, 0, 0, 0, 0, 0, 0, 0, 210 | /*8*/ ANDCF, ANDCF, ANDCF, ANDCF, ANDCF, ANDCF, ANDCF, ANDCF, 211 | ORCF, ORCF, ORCF, ORCF, ORCF, ORCF, ORCF, ORCF, 212 | /*9*/ XORCF, XORCF, XORCF, XORCF, XORCF, XORCF, XORCF, XORCF, 213 | LDCF, LDCF, LDCF, LDCF, LDCF, LDCF, LDCF, LDCF, 214 | /*A*/ STCF, STCF, STCF, STCF, STCF, STCF, STCF, STCF, 215 | TSET, TSET, TSET, TSET, TSET, TSET, TSET, TSET, 216 | /*B*/ RES, RES, RES, RES, RES, RES, RES, RES, 217 | SET, SET, SET, SET, SET, SET, SET, SET, 218 | /*C*/ CHG, CHG, CHG, CHG, CHG, CHG, CHG, CHG, 219 | BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, 220 | /*D*/ JP, JP, JP, JP, JP, JP, JP, JP, 221 | JP, JP, JP, JP, JP, JP, JP, JP, 222 | /*E*/ CALL, CALL, CALL, CALL, CALL, CALL, CALL, CALL, 223 | CALL, CALL, CALL, CALL, CALL, CALL, CALL, CALL, 224 | /*F*/ RET, RET, RET, RET, RET, RET, RET, RET, 225 | RET, RET, RET, RET, RET, RET, RET, RET 226 | }; 227 | 228 | //============================================================================= 229 | 230 | void TLCS900h_disassemble_dst(void) 231 | { 232 | second = get8_dis(); //Get the second opcode 233 | 234 | if (decode[second]) 235 | (*decode[second])(); 236 | else 237 | sprintf(instr, "unknown dst instr. %02X", second); 238 | } 239 | 240 | //============================================================================= 241 | #endif 242 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret_dst.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret_dst.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 22 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Added ANDCF,ORCF and XORCF in # and A modes. These were being used 34 | by one of the obscure pachinko "games". 35 | 36 | 23 JUL 2002 - neopop_uk 37 | ======================================= 38 | - Added cycle count for TSET. 39 | 40 | 16 AUG 2002 - neopop_uk 41 | ======================================= 42 | - Replaced 'second & 7' with 'R', clearer, faster - and for some reason 43 | more accurate... oh well! 44 | 45 | 21 AUG 2002 - neopop_uk 46 | ======================================= 47 | - Added TSET. 48 | 49 | //--------------------------------------------------------------------------- 50 | */ 51 | 52 | #include "neopop.h" 53 | #include "TLCS900h_interpret.h" 54 | #include "TLCS900h_registers.h" 55 | #include "mem.h" 56 | 57 | //========================================================================= 58 | 59 | //===== LD (mem),# 60 | void dstLDBi() 61 | { 62 | storeB(mem, FETCH8); 63 | cycles = 5; 64 | } 65 | 66 | //===== LD (mem),# 67 | void dstLDWi() 68 | { 69 | storeW(mem, fetch16()); 70 | cycles = 6; 71 | } 72 | 73 | //===== POP (mem) 74 | void dstPOPB() 75 | { 76 | storeB(mem, pop8()); 77 | cycles = 6; 78 | } 79 | 80 | //===== POP (mem) 81 | void dstPOPW() 82 | { 83 | storeW(mem, pop16()); 84 | cycles = 6; 85 | } 86 | 87 | //===== LD (mem),(nn) 88 | void dstLDBm16() 89 | { 90 | storeB(mem, loadB(fetch16())); 91 | cycles = 8; 92 | } 93 | 94 | //===== LD (mem),(nn) 95 | void dstLDWm16() 96 | { 97 | storeW(mem, loadW(fetch16())); 98 | cycles = 8; 99 | } 100 | 101 | //===== LDA R,mem 102 | void dstLDAW() 103 | { 104 | regW(R) = (_u16)mem; 105 | cycles = 4; 106 | } 107 | 108 | //===== LDA R,mem 109 | void dstLDAL() 110 | { 111 | regL(R) = (_u32)mem; 112 | cycles = 4; 113 | } 114 | 115 | //===== ANDCF A,(mem) 116 | void dstANDCFA() 117 | { 118 | _u8 bit = REGA & 0xF; 119 | _u8 mbit = (loadB(mem) >> bit) & 1; 120 | if (bit < 8) SETFLAG_C(mbit & FLAG_C); 121 | cycles = 8; 122 | } 123 | 124 | //===== ORCF A,(mem) 125 | void dstORCFA() 126 | { 127 | _u8 bit = REGA & 0xF; 128 | _u8 mbit = (loadB(mem) >> bit) & 1; 129 | if (bit < 8) SETFLAG_C(mbit | FLAG_C); 130 | cycles = 8; 131 | } 132 | 133 | //===== XORCF A,(mem) 134 | void dstXORCFA() 135 | { 136 | _u8 bit = REGA & 0xF; 137 | _u8 mbit = (loadB(mem) >> bit) & 1; 138 | if (bit < 8) SETFLAG_C(mbit ^ FLAG_C); 139 | cycles = 8; 140 | } 141 | 142 | //===== LDCF A,(mem) 143 | void dstLDCFA() 144 | { 145 | _u8 bit = REGA & 0xF; 146 | _u8 mask = (1 << bit); 147 | if (bit < 8) SETFLAG_C(loadB(mem) & mask); 148 | cycles = 8; 149 | } 150 | 151 | //===== STCF A,(mem) 152 | void dstSTCFA() 153 | { 154 | _u8 bit = REGA & 0xF; 155 | _u8 cmask = ~(1 << bit); 156 | _u8 set = FLAG_C << bit; 157 | if (bit < 8) storeB(mem, (loadB(mem) & cmask) | set); 158 | cycles = 8; 159 | } 160 | 161 | //===== LD (mem),R 162 | void dstLDBR() 163 | { 164 | storeB(mem, regB(R)); 165 | cycles = 4; 166 | } 167 | 168 | //===== LD (mem),R 169 | void dstLDWR() 170 | { 171 | storeW(mem, regW(R)); 172 | cycles = 4; 173 | } 174 | 175 | //===== LD (mem),R 176 | void dstLDLR() 177 | { 178 | storeL(mem, regL(R)); 179 | cycles = 6; 180 | } 181 | 182 | //===== ANDCF #3,(mem) 183 | void dstANDCF() 184 | { 185 | _u8 bit = R; 186 | _u8 mbit = (loadB(mem) >> bit) & 1; 187 | SETFLAG_C(mbit & FLAG_C); 188 | cycles = 8; 189 | } 190 | 191 | //===== ORCF #3,(mem) 192 | void dstORCF() 193 | { 194 | _u8 bit = R; 195 | _u8 mbit = (loadB(mem) >> bit) & 1; 196 | SETFLAG_C(mbit | FLAG_C); 197 | cycles = 8; 198 | } 199 | 200 | //===== XORCF #3,(mem) 201 | void dstXORCF() 202 | { 203 | _u8 bit = R; 204 | _u8 mbit = (loadB(mem) >> bit) & 1; 205 | SETFLAG_C(mbit ^ FLAG_C); 206 | cycles = 8; 207 | } 208 | 209 | //===== LDCF #3,(mem) 210 | void dstLDCF() 211 | { 212 | _u8 bit = R; 213 | _u32 mask = (1 << bit); 214 | SETFLAG_C(loadB(mem) & mask); 215 | cycles = 8; 216 | } 217 | 218 | //===== STCF #3,(mem) 219 | void dstSTCF() 220 | { 221 | _u8 bit = R; 222 | _u8 cmask = ~(1 << bit); 223 | _u8 set = FLAG_C << bit; 224 | storeB(mem, (loadB(mem) & cmask) | set); 225 | cycles = 8; 226 | } 227 | 228 | //===== TSET #3,(mem) 229 | void dstTSET() 230 | { 231 | SETFLAG_Z(! (loadB(mem) & (1 << R)) ); 232 | storeB(mem, loadB(mem) | (1 << R)); 233 | 234 | SETFLAG_H1 235 | SETFLAG_N0 236 | cycles = 10; 237 | } 238 | 239 | //===== RES #3,(mem) 240 | void dstRES() 241 | { 242 | storeB(mem, loadB(mem) & (~(1 << R))); 243 | cycles = 8; 244 | } 245 | 246 | //===== SET #3,(mem) 247 | void dstSET() 248 | { 249 | storeB(mem, loadB(mem) | (1 << R)); 250 | cycles = 8; 251 | } 252 | 253 | //===== CHG #3,(mem) 254 | void dstCHG() 255 | { 256 | storeB(mem, loadB(mem) ^ (1 << R)); 257 | cycles = 8; 258 | } 259 | 260 | //===== BIT #3,(mem) 261 | void dstBIT() 262 | { 263 | SETFLAG_Z(! (loadB(mem) & (1 << R)) ); 264 | SETFLAG_H1; 265 | SETFLAG_N0; 266 | cycles = 8; 267 | } 268 | 269 | //===== JP cc,mem 270 | void dstJP() 271 | { 272 | if (conditionCode(second & 0xF)) 273 | { 274 | pc = mem; 275 | cycles = 9; 276 | } 277 | else 278 | { 279 | cycles = 6; 280 | } 281 | } 282 | 283 | //===== CALL cc,mem 284 | void dstCALL() 285 | { 286 | if (conditionCode(second & 0xF)) 287 | { 288 | push32(pc); 289 | pc = mem; 290 | cycles = 12; 291 | } 292 | else 293 | { 294 | cycles = 6; 295 | } 296 | } 297 | 298 | //===== RET cc 299 | void dstRET() 300 | { 301 | if (conditionCode(second & 0xF)) 302 | { 303 | pc = pop32(); 304 | cycles = 12; 305 | } 306 | else 307 | { 308 | cycles = 6; 309 | } 310 | } 311 | 312 | //============================================================================= 313 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_disassemble_extra.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_disassemble_extra.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 02 SEP 2002 - neopop_uk 32 | ======================================= 33 | - Added the undocumented type 0x13 R32 address mode. 34 | 35 | //--------------------------------------------------------------------------- 36 | */ 37 | 38 | #ifdef NEOPOP_DEBUG 39 | //========================================================================= 40 | 41 | #include "neopop.h" 42 | #include "TLCS900h_disassemble.h" 43 | #include "TLCS900h_interpret.h" 44 | 45 | //========================================================================= 46 | 47 | char extra[32]; //Print the mnemonic for the addressing mode here. 48 | 49 | //========================================================================= 50 | 51 | static void ExXWA() {sprintf(extra, "XWA");} 52 | static void ExXBC() {sprintf(extra, "XBC");} 53 | static void ExXDE() {sprintf(extra, "XDE");} 54 | static void ExXHL() {sprintf(extra, "XHL");} 55 | static void ExXIX() {sprintf(extra, "XIX");} 56 | static void ExXIY() {sprintf(extra, "XIY");} 57 | static void ExXIZ() {sprintf(extra, "XIZ");} 58 | static void ExXSP() {sprintf(extra, "XSP");} 59 | 60 | static void ExXWAd() {sprintf(extra, "XWA %+d", (_s8)get8_dis());} 61 | static void ExXBCd() {sprintf(extra, "XBC %+d", (_s8)get8_dis());} 62 | static void ExXDEd() {sprintf(extra, "XDE %+d", (_s8)get8_dis());} 63 | static void ExXHLd() {sprintf(extra, "XHL %+d", (_s8)get8_dis());} 64 | static void ExXIXd() {sprintf(extra, "XIX %+d", (_s8)get8_dis());} 65 | static void ExXIYd() {sprintf(extra, "XIY %+d", (_s8)get8_dis());} 66 | static void ExXIZd() {sprintf(extra, "XIZ %+d", (_s8)get8_dis());} 67 | static void ExXSPd() {sprintf(extra, "XSP %+d", (_s8)get8_dis());} 68 | 69 | static void Ex8() {sprintf(extra, "0x%02X", get8_dis());} 70 | static void Ex16() {sprintf(extra, "0x%04X", get16_dis());} 71 | static void Ex24() {sprintf(extra, "0x%06X", get24_dis());} 72 | 73 | static void ExR32() 74 | { 75 | _u8 data = get8_dis(); 76 | 77 | if (data == 0x03) 78 | { 79 | _u8 rIndex, r32; 80 | r32 = get8_dis(); //r32, upper 6 bits 81 | rIndex = get8_dis(); //r8 / r16 82 | sprintf(extra, "%s + %s", 83 | regCodeName[2][r32 >> 2], regCodeName[0][rIndex >> 0]); 84 | return; 85 | } 86 | 87 | if (data == 0x07) 88 | { 89 | _u8 rIndex, r32; 90 | r32 = get8_dis(); //r32, upper 6 bits 91 | rIndex = get8_dis(); //r8 / r16 92 | sprintf(extra, "%s + %s", 93 | regCodeName[2][r32 >> 2], regCodeName[1][rIndex >> 1]); 94 | return; 95 | } 96 | 97 | //Undocumented mode. 98 | if (data == 0x13) 99 | { 100 | sprintf(extra, "pc %+d", (_s16)get16_dis()); 101 | return; 102 | } 103 | 104 | if ((data & 3) == 1) 105 | sprintf(extra, "%s %+d", regCodeName[2][data >> 2], (_s16)get16_dis()); 106 | else 107 | sprintf(extra, "%s", regCodeName[2][data >> 2]); 108 | } 109 | 110 | static void ExDec() 111 | { 112 | _u8 data = get8_dis(); 113 | _u8 r32 = data & 0xFC; 114 | 115 | switch(data & 3) 116 | { 117 | case 0: sprintf(extra, "1--%s", regCodeName[2][r32 >> 2]); break; 118 | case 1: sprintf(extra, "2--%s", regCodeName[2][r32 >> 2]); break; 119 | case 2: sprintf(extra, "4--%s", regCodeName[2][r32 >> 2]); break; 120 | } 121 | } 122 | 123 | static void ExInc() 124 | { 125 | _u8 data = get8_dis(); 126 | _u8 r32 = data & 0xFC; 127 | 128 | switch(data & 3) 129 | { 130 | case 0: sprintf(extra, "%s++1", regCodeName[2][r32 >> 2]); break; 131 | case 1: sprintf(extra, "%s++2", regCodeName[2][r32 >> 2]); break; 132 | case 2: sprintf(extra, "%s++4", regCodeName[2][r32 >> 2]); break; 133 | } 134 | } 135 | 136 | static void ExRCB() 137 | { 138 | _u8 data = get8_dis(); 139 | sprintf(extra, "%s", regCodeName[0][data >> 0]); 140 | brCode = TRUE; 141 | } 142 | 143 | static void ExRCW() 144 | { 145 | _u8 data = get8_dis(); 146 | sprintf(extra, "%s", regCodeName[1][data >> 1]); 147 | brCode = TRUE; 148 | } 149 | 150 | static void ExRCL() 151 | { 152 | _u8 data = get8_dis(); 153 | sprintf(extra, "%s", regCodeName[2][data >> 2]); 154 | brCode = TRUE; 155 | } 156 | 157 | //========================================================================= 158 | 159 | //Address Mode & Register Code 160 | static void (*decodeExtra[256])() = 161 | { 162 | /*0*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 163 | /*1*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 164 | /*2*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 165 | /*3*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 166 | /*4*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 167 | /*5*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 168 | /*6*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 169 | /*7*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 170 | /*8*/ ExXWA, ExXBC, ExXDE, ExXHL, ExXIX, ExXIY, ExXIZ, ExXSP, 171 | ExXWAd, ExXBCd, ExXDEd, ExXHLd, ExXIXd, ExXIYd, ExXIZd, ExXSPd, 172 | /*9*/ ExXWA, ExXBC, ExXDE, ExXHL, ExXIX, ExXIY, ExXIZ, ExXSP, 173 | ExXWAd, ExXBCd, ExXDEd, ExXHLd, ExXIXd, ExXIYd, ExXIZd, ExXSPd, 174 | /*A*/ ExXWA, ExXBC, ExXDE, ExXHL, ExXIX, ExXIY, ExXIZ, ExXSP, 175 | ExXWAd, ExXBCd, ExXDEd, ExXHLd, ExXIXd, ExXIYd, ExXIZd, ExXSPd, 176 | /*B*/ ExXWA, ExXBC, ExXDE, ExXHL, ExXIX, ExXIY, ExXIZ, ExXSP, 177 | ExXWAd, ExXBCd, ExXDEd, ExXHLd, ExXIXd, ExXIYd, ExXIZd, ExXSPd, 178 | /*C*/ Ex8, Ex16, Ex24, ExR32, ExDec, ExInc, 0, ExRCB, 179 | 0, 0, 0, 0, 0, 0, 0, 0, 180 | /*D*/ Ex8, Ex16, Ex24, ExR32, ExDec, ExInc, 0, ExRCW, 181 | 0, 0, 0, 0, 0, 0, 0, 0, 182 | /*E*/ Ex8, Ex16, Ex24, ExR32, ExDec, ExInc, 0, ExRCL, 183 | 0, 0, 0, 0, 0, 0, 0, 0, 184 | /*F*/ Ex8, Ex16, Ex24, ExR32, ExDec, ExInc, 0, 0, 185 | 0, 0, 0, 0, 0, 0, 0, 0 186 | }; 187 | 188 | void TLCS900h_disassemble_extra(void) 189 | { 190 | //Is any extra data used by this instruction? 191 | if (decodeExtra[first]) 192 | (*decodeExtra[first])(); 193 | } 194 | 195 | //========================================================================= 196 | #endif 197 | 198 | -------------------------------------------------------------------------------- /Core/neopop.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | neopop.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 01 AUG 2002 - neopop_uk 32 | ======================================= 33 | - Added support for frameskipping. 34 | 35 | 15 AUG 2002 - neopop_uk 36 | ======================================= 37 | - Changed to the new timer functions. This makes graphical effects 38 | in "Memories Off Pure" stop flickering, and likely improves some others. 39 | 40 | 30 AUG 2002 - neopop_uk 41 | ======================================= 42 | - Removed frameskipping. 43 | 44 | 09 SEP 2002 - neopop_uk 45 | ======================================= 46 | - Unified timer calls now cycles are correct. 47 | 48 | //--------------------------------------------------------------------------- 49 | */ 50 | 51 | #include "neopop.h" 52 | #include "TLCS900h_interpret.h" 53 | #include "TLCS900h_registers.h" 54 | #include "Z80_interface.h" 55 | #include "interrupt.h" 56 | #include "mem.h" 57 | 58 | //============================================================================= 59 | 60 | BOOL language_english; 61 | 62 | COLOURMODE system_colour; 63 | 64 | _u8 frameskip_count; 65 | 66 | //============================================================================= 67 | 68 | static BOOL debug_abort_instruction = FALSE; 69 | void __cdecl instruction_error(char* vaMessage,...) 70 | { 71 | char message[1000]; 72 | va_list vl; 73 | 74 | va_start(vl, vaMessage); 75 | vsprintf(message, vaMessage, vl); 76 | va_end(vl); 77 | 78 | #ifdef NEOPOP_DEBUG 79 | system_debug_message(message); 80 | debug_abort_instruction = TRUE; 81 | #else 82 | system_message("[PC %06X] %s", pc, message); 83 | #endif 84 | } 85 | 86 | //============================================================================= 87 | 88 | #ifndef NEOPOP_DEBUG 89 | 90 | void emulate(void) 91 | { 92 | _u8 i; 93 | 94 | //Execute several instructions to boost performance 95 | for (i = 0; i < 64; i++) 96 | { 97 | updateTimers(TLCS900h_interpret()); 98 | if (Z80ACTIVE) Z80EMULATE 99 | updateTimers(TLCS900h_interpret()); 100 | } 101 | } 102 | 103 | #endif 104 | 105 | //============================================================================= 106 | 107 | #ifdef NEOPOP_DEBUG 108 | 109 | #include "TLCS900h_disassemble.h" 110 | 111 | //Debug Message Filters 112 | BOOL filter_sound; 113 | BOOL filter_bios; 114 | BOOL filter_comms; 115 | BOOL filter_dma; 116 | BOOL filter_mem; 117 | 118 | char* disassemble(void) 119 | { 120 | if (pc >= 0x7000 && pc <= 0x7FFF) 121 | { 122 | char* s; 123 | _u16 p = (_u16)(pc & 0xFFF); 124 | s = Z80_disassemble(&p); 125 | pc = p + 0x7000; 126 | return s; 127 | } 128 | else 129 | return TLCS900h_disassemble(); 130 | } 131 | 132 | void emulate_debug(BOOL dis_TLCS900h, BOOL dis_Z80) 133 | { 134 | _u32 storePC = pc; 135 | 136 | debug_abort_memory = FALSE; 137 | debug_abort_instruction = FALSE; 138 | 139 | system_debug_history_add(); //For the debugger 140 | 141 | if (dis_TLCS900h) 142 | { 143 | char* s; 144 | 145 | //Disassemble TLCS-900h 146 | _u32 oldpc = pc; 147 | s = disassemble(); 148 | system_debug_message(s); 149 | system_debug_message_associate_address(oldpc); 150 | free(s); 151 | pc = oldpc; 152 | } 153 | 154 | if (dis_Z80) 155 | { 156 | //Disassemble Z80 157 | if (Z80ACTIVE) 158 | { 159 | char* s; 160 | _u16 pc = Z80_getReg(Z80_REG_PC); 161 | _u16 store_pc = pc; 162 | 163 | //Disassemble 164 | s = Z80_disassemble(&pc); 165 | system_debug_message(s); 166 | system_debug_message_associate_address(store_pc + 0x7000); 167 | free(s); 168 | } 169 | } 170 | 171 | debug_abort_memory = FALSE; 172 | debug_abort_instruction = FALSE; 173 | 174 | //================== 175 | // EMULATE 176 | //================== 177 | { 178 | //TLCS900h instruction 179 | updateTimers(TLCS900h_interpret()); 180 | 181 | //Z80 Instruction 182 | if (Z80ACTIVE) Z80EMULATE; 183 | } 184 | 185 | //Check register code error 186 | if (rErr != RERR_VALUE) 187 | instruction_error("Invalid register code used."); 188 | 189 | //Memory Exception 190 | if (debug_abort_memory && filter_mem) 191 | { 192 | _u32 oldpc = pc; 193 | char* s; 194 | 195 | debug_abort_memory = FALSE; 196 | 197 | //Try to disassemble the erroneous instruction 198 | pc = storePC; 199 | debug_mask_memory_error_messages = TRUE; 200 | s = disassemble(); 201 | debug_mask_memory_error_messages = FALSE; 202 | 203 | if (debug_abort_memory == FALSE) 204 | { 205 | system_debug_message("Stopped due to memory exception caused by"); 206 | system_debug_message(" %s", s); 207 | system_debug_message_associate_address(storePC); 208 | system_debug_message("\n"); 209 | } 210 | else 211 | { 212 | system_debug_message("Stopped due to memory exception caused at %06X", storePC); 213 | system_debug_message_associate_address(storePC); 214 | } 215 | free(s); 216 | pc = oldpc; 217 | 218 | system_debug_stop(); 219 | system_debug_refresh(); 220 | return; 221 | } 222 | 223 | //Unimplemented Instruction 224 | if (debug_abort_instruction) 225 | { 226 | _u32 oldpc = pc; 227 | char* s; 228 | 229 | debug_abort_memory = FALSE; 230 | 231 | //Try to disassemble the erroneous instruction 232 | pc = storePC; 233 | debug_mask_memory_error_messages = TRUE; 234 | s = disassemble(); 235 | debug_mask_memory_error_messages = FALSE; 236 | 237 | if (debug_abort_memory == FALSE) 238 | { 239 | system_debug_message("Stopped due to instruction"); 240 | system_debug_message(" %s", s); 241 | system_debug_message_associate_address(storePC); 242 | system_debug_message("\n"); 243 | } 244 | else 245 | { 246 | system_debug_message("Stopped due to instruction at %06X", storePC); 247 | system_debug_message_associate_address(storePC); 248 | } 249 | free(s); 250 | pc = oldpc; 251 | 252 | system_debug_stop(); 253 | system_debug_refresh(); 254 | return; 255 | } 256 | } 257 | 258 | #endif 259 | 260 | //============================================================================= 261 | 262 | -------------------------------------------------------------------------------- /Core/docs/changelog.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------ 2 | Core\docs\changelog.txt 3 | ------------------------------------------------------ 4 | Alterations made to the Emulation Core. 5 | ------------------------------------------------------ 6 | 7 | 03 AUG 2002 - neopop_uk 8 | ======================= 9 | - Restructured and flattened the file layout to make it easier to 10 | integrate other source ports. 11 | - Removed disassemble.c/h - moved the 'disassemble' function to neopop.c 12 | - Added filename comments to that start of all source files. 13 | - Made 'mute' a common variable. 14 | 15 | 04 AUG 2002 - neopop_uk 16 | ======================= 17 | - Removed the header links between the system and core code. These 18 | linked sections are now unified in 'neopop.h' 19 | 20 | 06 AUG 2002 - neopop_uk 21 | ======================= 22 | - Internal rendering is now done in 16 bit, not 32. This will improve 23 | performance a great deal. The pixel format is "X4B4G4R4", if that helps! 24 | 25 | 09 AUG 2002 - neopop_uk 26 | ======================= 27 | - I've removed support for CPU halting, to squeeze out a few extra cycles. 28 | 29 | 10 AUG 2002 - neopop_uk 30 | ======================= 31 | - Added better default memory setup to try and fool some of the 'clever' 32 | games into thinking they're running on a real machine. 33 | - Tracked down and fixed why "Metal Slug 2" wasn't making 34 | it's in-game voices. 35 | 36 | - Added simple emulation of direct EEPROM access. This lets more games 37 | save their settings correctly. This fixes KOF-R2 making mode as well. 38 | 39 | - Changed the way that flash acceses work, 'flash_write' no longer 40 | writes the flash data to the i/o. This task is undertaken by 'flash_commit'. 41 | This was necessary because direct EEPROM access was killing performance. 42 | 'flash_commit' is called when rom_unload is called - In the Windows port 43 | this means when unloading, loading a new rom or quiting. 44 | 45 | - Added raster horizontal position emulation, fixes "NeoGeo Cup '98 Plus Color" 46 | 47 | 15 AUG 2002 - neopop_uk 48 | ======================= 49 | - To make the code more compatible with other compilers, i've changed the 50 | bool type, defined in neopop.h, to BOOL - which is a typedef of int. This 51 | has changed nothing in the Windows port, but should fix other compilers. 52 | Also 'true' and 'false' have been replaced with #defined symbols TRUE and FALSE 53 | 54 | - A bug has been discovered in 'drawPattern' as the 4th parameter 'mirror' 55 | was given type bool - when it should really be _u16. This applies to 56 | gfx_scanline_colour.c and gfx_scanline_mono.c. 57 | 58 | - Another fix applies only the mono core, and the Plot function. The 59 | file itself has a description of the change. 60 | 61 | - Minor changes to 'state.c/h' to remove the 'halt' state and replace it 62 | with the storage of 'eepromStatusEnable'. Neither of these values were 63 | likely to have been set, but this new saving is more accurate. 64 | 65 | 15 AUG 2002 - neopop_uk 66 | ======================= 67 | - I've made the horizontal interrupt code be run after every instruction 68 | this makes the timing more accurate and fixes the fading effects of the 69 | 'Memories Off Pure' intro. 70 | 71 | 16 AUG 2002 - neopop_uk 72 | ======================= 73 | - I've done a little optimisation work on the graphics core. 74 | - Fixed the bad notes in the sound emulation - one chip does just the 75 | noise channel, the other does tone generation. There is no need for 76 | a stereo/mono option now... 77 | - Fixed bugs in register storing destination, seemed important, but it's 78 | had little effect on compatiblity so far... 79 | - Fixed V flag emulation of INC/DEC, fixes "Cotton" menus 80 | 81 | 18 AUG 2002 - neopop_uk 82 | ======================= 83 | - I've moved more stuff out of the local header files and into neopop.h 84 | This includes: RomInfo, RonHeader, state_store, state_restore. 85 | This is all so that no core header files have to be included by the 86 | system specific code - only neopop.h. This will ensure any internal changes 87 | will not affect future versions. In turn this will hopefully allow older 88 | system code to work with a newer core, and vice-versa. 89 | - Removed 'rom.h' file because all of it's components were moved to NeoPop.h 90 | - Added string support for all non-debug system messages. 91 | 92 | 21 AUG 2002 - neopop_uk 93 | ======================================= 94 | - Fixed "RR (mem)" - It was actually the [REG] version that hadn't been 95 | changed to use memory accesses - oops!. 96 | - Fixed potential precidence problems in regX and rCodeX by using ()'s 97 | - Added TSET and MULA instructions, untested. 98 | 99 | 22 AUG 2002 - neopop_uk 100 | ======================================= 101 | - Added correct DMA chaining behaviour. If a DMA trigger is assigned to 102 | multiple channels, then the channel with the lowest index must complete it's 103 | transfer before the next one is activated. 104 | 105 | 22 AUG 2002 - neopop_uk 106 | ======================================= 107 | - Made the code compile with the "GCC v2.95.3-5 (cygwin special)" compiler. 108 | 109 | 28 AUG 2002 - neopop_uk 110 | ======================================= 111 | - Added implementations for most of the comms bios functions using the 112 | new comms system functions. I'm not sure if RTS emulation is 113 | required at the moment. I believe that flow control and handshaking can be 114 | done at a level higher than the NGPC knows about, so to it comms will always 115 | work right on time... but there may be timing issues to resolve... 116 | 117 | 30 AUG 2002 - neopop_uk 118 | ======================================= 119 | - Fixed "DIV RR,(mem)" in long mode, wrong operand size. 120 | 121 | - Added comms. read and write interrupt/dma calls. This has made many more 122 | games allow their link-up options. However, I have been unable to test them 123 | with a real network, so I'm unsure if the frequent link errors that occur 124 | happen to all users... 125 | 126 | - Improved 'R32' memory addressing mode. Fixes a crashing bug in "Card Fighters". 127 | 128 | 02 SEP 2002 - neopop_uk 129 | ======================================= 130 | - Added the undocumented type 0x13 R32 address mode. 131 | 132 | 04 SEP 2002 - neopop_uk 133 | ======================================= 134 | - Made the code really compile with GCC. 135 | 136 | 06 SEP 2002 - neopop_uk 137 | ======================================= 138 | - Added better emulation of comms system memory at ram[0x50]. 139 | 140 | 07 SEP 2002 - neopop_uk 141 | ======================================= 142 | - Made the direct EEPROM access more secure by requiring an EEPROM 143 | command to be issued before every write. This isn't perfect, but it 144 | should stop "Gals Fighters" from writing all over itself. 145 | 146 | ################ 0.70 RELEASE ################## 147 | 148 | 08 SEP 2002 - neopop_uk 149 | ======================================= 150 | - Made flash writes more robust be eliminating a possible logic error. 151 | 152 | 09 SEP 2002 - neopop_uk 153 | ======================================= 154 | - Extra cycles for addressing modes. 155 | - Optimised and unified timer updates, adjusted the rates now that 156 | extra cycles have been accounted for. Verified from "Cool Cool Jam" that 157 | the timing is pretty accurate. 158 | 159 | 10 SEP 2002 - neopop_uk 160 | ======================================= 161 | - Added frameskipping again, not as slow as I originally thought. 162 | 163 | ################ 0.71 RELEASE ################## 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /System_PSP/neopop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "psplib/pl_file.h" 7 | #include "psplib/image.h" 8 | #include "psplib/video.h" 9 | 10 | #include "neopop.h" 11 | 12 | extern PspImage *Screen; 13 | pl_file_path SaveStatePath; 14 | extern char *GameName; 15 | 16 | typedef struct 17 | { 18 | char label[9]; 19 | char string[256]; 20 | } 21 | STRING_TAG; 22 | 23 | /* TODO */ 24 | const char *FlashDirectory = "."; 25 | 26 | static STRING_TAG string_tags[STRINGS_MAX] = 27 | { 28 | //NOTE: This ordering must match the enumeration 'STRINGS' in neopop.h 29 | 30 | { "SDEFAULT", "Are you sure you want to revert to the default control setup?" }, 31 | { "ROMFILT", "Rom Files (*.ngp,*.ngc,*.npc,*.zip)\0*.ngp;*.ngc;*.npc;*.zip\0\0" }, 32 | { "STAFILT", "State Files (*.ngs)\0*.ngs\0\0" }, 33 | { "FLAFILT", "Flash Memory Files (*.ngf)\0*.ngf\0\0" }, 34 | { "BADFLASH", "The flash data for this rom is from a different version of NeoPop, it will be destroyed soon." }, 35 | { "POWER", "The system has been signalled to power down. You must reset or load a new rom." }, 36 | { "BADSTATE", "State is from an unsupported version of NeoPop." }, 37 | { "ERROR1", "An error has occured creating the application window" }, 38 | { "ERROR2", "An error has occured initialising DirectDraw" }, 39 | { "ERROR3", "An error has occured initialising DirectInput" }, 40 | { "TIMER", "This system does not have a high resolution timer." }, 41 | { "WRONGROM", "This state is from a different rom, Ignoring." }, 42 | { "EROMFIND", "Cannot find ROM file" }, 43 | { "EROMOPEN", "Cannot open ROM file" }, 44 | { "EZIPNONE", "No roms found" }, 45 | { "EZIPBAD", "Corrupted ZIP file" }, 46 | { "EZIPFIND", "Cannot find ZIP file" }, 47 | 48 | { "ABORT", "Abort" }, 49 | { "DISCON", "Disconnect" }, 50 | { "CONNEC", "Connected." }, 51 | }; 52 | 53 | /*! Used to generate a critical message for the user. After the message 54 | has been displayed, the function should return. The message is not 55 | necessarily a fatal error. */ 56 | 57 | void system_message(char* vaMessage,...) 58 | { 59 | #ifdef PSP_DEBUG 60 | FILE *debug = fopen("message.txt", "a"); 61 | 62 | va_list vl; 63 | va_start(vl, vaMessage); 64 | vfprintf(debug, vaMessage, vl); 65 | va_end(vl); 66 | 67 | fclose(debug); 68 | #endif 69 | } 70 | 71 | /*! Get a string that may possibly be translated */ 72 | 73 | char* system_get_string(STRINGS string_id) 74 | { 75 | if (string_id >= STRINGS_MAX) 76 | return "Unknown String"; 77 | 78 | return string_tags[string_id].string; 79 | } 80 | 81 | /*! Reads a byte from the other system. If no data is available or no 82 | high-level communications have been established, then return FALSE. 83 | If buffer is NULL, then no data is read, only status is returned */ 84 | 85 | BOOL system_comms_read(_u8* buffer) 86 | { 87 | return 0; 88 | } 89 | 90 | /*! Writes a byte from the other system. This function should block until 91 | the data is written. USE RELIABLE COMMS! Data cannot be re-requested. */ 92 | 93 | void system_comms_write(_u8 data) 94 | { 95 | return; 96 | } 97 | 98 | /*! Peeks at any data from the other system. If no data is available or 99 | no high-level communications have been established, then return FALSE. 100 | If buffer is NULL, then no data is read, only status is returned */ 101 | 102 | BOOL system_comms_poll(_u8* buffer) 103 | { 104 | return 0; 105 | } 106 | 107 | /*! Reads from the file specified by 'filename' into the given preallocated 108 | buffer. This is state data. */ 109 | 110 | BOOL system_io_state_read(char* filename, _u8* buffer, _u32 bufferLength) 111 | { 112 | /* Open file for reading */ 113 | FILE *f = fopen(filename, "r"); 114 | if (!f) return 0; 115 | 116 | /* Load image into temporary object */ 117 | PspImage *image = pspImageLoadPngFd(f); 118 | pspImageDestroy(image); 119 | 120 | /* Load state data */ 121 | fread(buffer, bufferLength, sizeof(_u8), f); 122 | fclose(f); 123 | 124 | return 1; 125 | } 126 | 127 | /*! Writes to the file specified by 'filename' from the given buffer. 128 | This is state data. */ 129 | 130 | BOOL system_io_state_write(char* filename, _u8* buffer, _u32 bufferLength) 131 | { 132 | /* Open file for writing */ 133 | FILE *f; 134 | if (!(f = fopen(filename, "w"))) return 0; 135 | 136 | /* Create copy of screen */ 137 | PspImage *copy; 138 | if (!(copy = pspImageCreateCopy(Screen))) 139 | { 140 | fclose(f); 141 | return 0; 142 | } 143 | 144 | /* Correct for color (4444 to 5551) */ 145 | int i, j, r, g, b; 146 | for (i = copy->Viewport.Y + copy->Viewport.Height; i >= copy->Viewport.Y; i--) 147 | { 148 | for (j = copy->Viewport.X + copy->Viewport.Width; j >= copy->Viewport.X; j--) 149 | { 150 | _u16 *pixel = &((_u16*)copy->Pixels)[i * copy->Width + j]; 151 | 152 | r = ((*pixel & 0xf) * 0xff / 0xf); 153 | g = (((*pixel >> 4) & 0xf) * 0xff / 0xf); 154 | b = (((*pixel >> 8) & 0xf) * 0xff / 0xf); 155 | 156 | *pixel = RGB(r,g,b); 157 | } 158 | } 159 | 160 | /* Write the screenshot */ 161 | if (!pspImageSavePngFd(f, copy)) 162 | { 163 | fclose(f); 164 | pspImageDestroy(copy); 165 | return 0; 166 | } 167 | 168 | pspImageDestroy(copy); 169 | 170 | /* Write state data */ 171 | fwrite(buffer, bufferLength, sizeof(_u8), f); 172 | fclose(f); 173 | 174 | return 1; 175 | } 176 | 177 | /*! Reads the "appropriate" (system specific) flash data into the given 178 | preallocated buffer. The emulation core doesn't care where from. */ 179 | 180 | BOOL system_io_flash_read(_u8* buffer, _u32 bufferLength) 181 | { 182 | char *path; 183 | printf("get_filename %s",SaveStatePath); 184 | const char *config_name = pl_file_get_filename(GameName); 185 | path = (char*)malloc(strlen(SaveStatePath) + strlen(config_name) + 8); 186 | sprintf(path, "%s%s.ngf", SaveStatePath, config_name); 187 | printf("%s",path); 188 | FILE* file; 189 | if ((file = fopen(path, "r"))) 190 | { 191 | fread(buffer, bufferLength, sizeof(_u8), file); 192 | fclose(file); 193 | } 194 | 195 | free(path); 196 | return file != NULL; 197 | } 198 | 199 | /*! Writes the given flash data into an "appropriate" (system specific) 200 | place. The emulation core doesn't care where to. */ 201 | 202 | BOOL system_io_flash_write(_u8* buffer, _u32 bufferLength) 203 | { 204 | char *path; 205 | const char *config_name = pl_file_get_filename(GameName); 206 | path = (char*)malloc(strlen(SaveStatePath) + strlen(config_name) + 8); 207 | sprintf(path, "%s%s.ngf", SaveStatePath, config_name); 208 | 209 | FILE* file; 210 | if ((file = fopen(path, "w"))) 211 | { 212 | fwrite(buffer, bufferLength, sizeof(_u8), file); 213 | fclose(file); 214 | } 215 | 216 | free(path); 217 | return file != NULL; 218 | } 219 | 220 | /*! Reads as much of the file specified by 'filename' into the given, 221 | preallocated buffer. This is rom data */ 222 | 223 | BOOL system_io_rom_read(char* filename, _u8* buffer, _u32 bufferLength) 224 | { 225 | FILE* file; 226 | file = fopen(filename, "rb"); 227 | 228 | if (file) 229 | { 230 | fread(buffer, bufferLength, sizeof(_u8), file); 231 | fclose(file); 232 | return TRUE; 233 | } 234 | 235 | return FALSE; 236 | } 237 | 238 | /*! Callback for "sound_init" with the system sound frequency */ 239 | 240 | void system_sound_chipreset() 241 | { 242 | /* Initialises sound chips, matching frequncies */ 243 | sound_init(CHIP_FREQUENCY); 244 | } 245 | 246 | /*! Clears the sound output. */ 247 | 248 | void system_sound_silence() 249 | { 250 | } 251 | -------------------------------------------------------------------------------- /System_PSP/emulate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #include 7 | #include 8 | 9 | #include "neopop.h" 10 | 11 | #include "emulate.h" 12 | #include "emumenu.h" 13 | 14 | #include "psplib/pl_file.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | PspImage *Screen; 24 | PspImage *BG3X; 25 | 26 | static pl_perf_counter FpsCounter; 27 | static int ScreenX, ScreenY, ScreenW, ScreenH; 28 | static int ClearScreen; 29 | static int TicksPerUpdate; 30 | static u32 TicksPerSecond; 31 | static u64 LastTick; 32 | static u64 CurrentTick; 33 | static unsigned char ReturnToMenu; 34 | 35 | extern char *GameName; 36 | extern EmulatorOptions Options; 37 | extern const u64 ButtonMask[]; 38 | extern const int ButtonMapId[]; 39 | extern struct ButtonConfig ActiveConfig; 40 | extern char *ScreenshotPath; 41 | 42 | static void AudioCallback(pl_snd_sample* buf, 43 | unsigned int samples, 44 | void *userdata); 45 | _u8 system_frameskip_key; 46 | 47 | /* Initialize emulation */ 48 | int InitEmulation() 49 | { 50 | /* Initialize BIOS */ 51 | if (!bios_install()) return 0; 52 | 53 | /* Basic emulator initialization */ 54 | language_english = TRUE; 55 | system_colour = COLOURMODE_AUTO; 56 | 57 | /* Create screen buffer */ 58 | if (!(Screen = pspImageCreateVram(256, 256, GU_PSM_4444))) 59 | return 0; 60 | 61 | Screen->Viewport.Width = SCREEN_WIDTH; 62 | Screen->Viewport.Height = SCREEN_HEIGHT; 63 | cfb = Screen->Pixels; 64 | 65 | pl_file_path background; 66 | snprintf(background, sizeof(background) - 1, "%sbg3x.png", "app0:/" 67 | /*pl_psp_get_app_directory()*/); 68 | BG3X = pspImageLoadPng2D(background); 69 | 70 | pl_snd_set_callback(0, AudioCallback, NULL); 71 | 72 | 73 | return 1; 74 | } 75 | 76 | void system_graphics_update() 77 | { 78 | pspVideoBegin(); 79 | 80 | /* Clear the buffer first, if necessary */ 81 | if (ClearScreen >= 0) 82 | { 83 | ClearScreen--; 84 | pspVideoClearScreen(); 85 | } 86 | 87 | /* Blit screen */ 88 | //sceGuDisable(GU_BLEND); 89 | pspVideoPutImage(Screen, ScreenX, ScreenY, ScreenW, ScreenH); 90 | //printf("%d %d %d %d", ScreenX, ScreenY, ScreenW, ScreenH); 91 | //sceGuEnable(GU_BLEND); 92 | 93 | 94 | if(Options.DisplayMode==DISPLAY_MODE_3X_BG&&BG3X){ 95 | pspVideoPutImage(BG3X, 0, 0, SCR_WIDTH, SCR_HEIGHT); 96 | } 97 | /* Show FPS counter */ 98 | if (Options.ShowFps) 99 | { 100 | static char fps_display[32]; 101 | sprintf(fps_display, " %3.02f", pl_perf_update_counter(&FpsCounter)); 102 | 103 | int width = pspFontGetTextWidth(&PspStockFont, fps_display); 104 | int height = pspFontGetLineHeight(&PspStockFont); 105 | 106 | pspVideoFillRect(SCR_WIDTH - width, 0, SCR_WIDTH, height, PSP_COLOR_BLACK); 107 | pspVideoPrint(&PspStockFont, SCR_WIDTH - width, 0, fps_display, PSP_COLOR_WHITE); 108 | } 109 | 110 | pspVideoEnd(); 111 | 112 | /* Wait if needed */ 113 | if (Options.UpdateFreq) 114 | { 115 | do { sceRtcGetCurrentTick(&CurrentTick); } 116 | while (CurrentTick - LastTick < TicksPerUpdate); 117 | LastTick = CurrentTick; 118 | } 119 | 120 | /* Wait for VSync signal */ 121 | if (Options.VSync) 122 | pspVideoWaitVSync(); 123 | 124 | /* Swap buffers */ 125 | pspVideoSwapBuffers(); 126 | 127 | } 128 | 129 | void system_input_update() 130 | { 131 | _u8 *input_ptr = &ram[0x6F82]; 132 | 133 | /* Reset input */ 134 | *input_ptr = 0; 135 | 136 | static SceCtrlData pad; 137 | 138 | /* Check the input */ 139 | if (pspCtrlPollControls(&pad)) 140 | { 141 | #ifdef PSP_DEBUG 142 | if ((pad.buttons & (PSP_CTRL_SELECT | PSP_CTRL_START)) 143 | == (PSP_CTRL_SELECT | PSP_CTRL_START)) 144 | pspUtilSaveVramSeq(ScreenshotPath, "game"); 145 | #endif 146 | 147 | /* Parse input */ 148 | int i, on, code; 149 | for (i = 0; ButtonMapId[i] >= 0; i++) 150 | { 151 | code = ActiveConfig.ButtonMap[ButtonMapId[i]]; 152 | on = (pad.buttons & ButtonMask[i]) == ButtonMask[i]; 153 | 154 | /* Check to see if a button set is pressed. If so, unset it, so it */ 155 | /* doesn't trigger any other combination presses. */ 156 | //if (on) pad.buttons &= ~ButtonMask[i]; 157 | 158 | if (code & JOY) 159 | { 160 | if (on) *input_ptr |= CODE_MASK(code); 161 | continue; 162 | } 163 | else if (code & SPC) 164 | { 165 | switch (CODE_MASK(code)) 166 | { 167 | case SPC_MENU: 168 | ReturnToMenu = on; break; 169 | } 170 | } 171 | } 172 | } 173 | } 174 | 175 | /*! Called at the start of the vertical blanking period */ 176 | void system_VBL(void) 177 | { 178 | /* Update Graphics */ 179 | if (frameskip_count == 0) 180 | system_graphics_update(); 181 | 182 | /* Update Input */ 183 | system_input_update(); 184 | 185 | /* Sound update performed in the callback */ 186 | } 187 | 188 | /* Run emulation */ 189 | void RunEmulation() 190 | { 191 | float ratio; 192 | 193 | /* Recompute screen size/position */ 194 | switch (Options.DisplayMode) 195 | { 196 | default: 197 | case DISPLAY_MODE_UNSCALED: 198 | ScreenW = Screen->Viewport.Width; 199 | ScreenH = Screen->Viewport.Height; 200 | break; 201 | case DISPLAY_MODE_FIT_HEIGHT: 202 | ratio = (float)SCR_HEIGHT / (float)Screen->Viewport.Height; 203 | ScreenW = (float)Screen->Viewport.Width * ratio; 204 | ScreenH = SCR_HEIGHT; 205 | break; 206 | case DISPLAY_MODE_FILL_SCREEN: 207 | ScreenW = SCR_WIDTH; 208 | ScreenH = SCR_HEIGHT; 209 | break; 210 | case DISPLAY_MODE_2X: 211 | ScreenW = Screen->Viewport.Width*2; 212 | ScreenH = Screen->Viewport.Height*2; 213 | break; 214 | case DISPLAY_MODE_3X: 215 | case DISPLAY_MODE_3X_BG: 216 | ScreenW = Screen->Viewport.Width*3; 217 | ScreenH = Screen->Viewport.Height*3; 218 | break; 219 | } 220 | 221 | 222 | 223 | ScreenX = (SCR_WIDTH / 2) - (ScreenW / 2); 224 | ScreenY = (SCR_HEIGHT / 2) - (ScreenH / 2); 225 | 226 | /* Init performance counter */ 227 | pl_perf_init_counter(&FpsCounter); 228 | 229 | /* Recompute update frequency */ 230 | TicksPerSecond = sceRtcGetTickResolution(); 231 | if (Options.UpdateFreq) 232 | { 233 | TicksPerUpdate = TicksPerSecond 234 | / (Options.UpdateFreq - (Options.Frameskip)); 235 | sceRtcGetCurrentTick(&LastTick); 236 | } 237 | 238 | 239 | system_frameskip_key = Options.Frameskip + 1; /* 1 - 7 */ 240 | ReturnToMenu = 0; 241 | ClearScreen = 2; 242 | 243 | 244 | /* Initiate sound */ 245 | pl_snd_resume(0); 246 | 247 | /* Wait for V. refresh */ 248 | pspVideoWaitVSync(); 249 | 250 | /* Emulation loop */ 251 | while (!ExitPSP && !ReturnToMenu) 252 | emulate(); 253 | 254 | /* Stop sound */ 255 | pl_snd_pause(0); 256 | 257 | } 258 | 259 | static void AudioCallback(pl_snd_sample* buf, 260 | unsigned int samples, 261 | void *userdata){ 262 | 263 | int length_bytes = samples << 2; /* 4 bytes per stereo sample */ 264 | 265 | /* If the sound buffer's not ready, render silence */ 266 | if (ExitPSP || ReturnToMenu) memset(buf, 0, length_bytes); 267 | else sound_update_stereo((_u16*)buf, length_bytes); 268 | } 269 | 270 | 271 | 272 | /* Release emulation resources */ 273 | void TrashEmulation() 274 | { 275 | pspImageDestroy(Screen); 276 | if(BG3X) 277 | pspImageDestroy(BG3X); 278 | } 279 | -------------------------------------------------------------------------------- /Core/TLCS-900h/TLCS900h_interpret_single.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // NEOPOP : Emulator as in Dreamland 3 | // 4 | // Copyright (c) 2001-2002 by neopop_uk 5 | //--------------------------------------------------------------------------- 6 | 7 | //--------------------------------------------------------------------------- 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. See also the license.txt file for 12 | // additional informations. 13 | //--------------------------------------------------------------------------- 14 | 15 | /* 16 | //--------------------------------------------------------------------------- 17 | //========================================================================= 18 | 19 | TLCS900h_interpret_single.c 20 | 21 | //========================================================================= 22 | //--------------------------------------------------------------------------- 23 | 24 | History of changes: 25 | =================== 26 | 27 | 20 JUL 2002 - neopop_uk 28 | ======================================= 29 | - Cleaned and tidied up for the source release 30 | 31 | 22 JUL 2002 - neopop_uk 32 | ======================================= 33 | - Removed setting the register file pointer to 3 in the SWI instruction 34 | This has fixed "Metal Slug 2" and flash saving in many games. 35 | 36 | 26 JUL 2002 - neopop_uk 37 | ======================================= 38 | - Prefixed all instruction functions with "sng" to avoid a repeat of the 39 | the 'EX' fiasco. 40 | 41 | 30 JUL 2002 - neopop_uk 42 | ======================================= 43 | - Um... SWI doesn't cause a problem if IFF is set to 3... why did 44 | "Metal Slug 2" start working??? 45 | 46 | //--------------------------------------------------------------------------- 47 | */ 48 | 49 | #include "neopop.h" 50 | #include "TLCS900h_interpret.h" 51 | #include "TLCS900h_registers.h" 52 | #include "mem.h" 53 | #include "interrupt.h" 54 | 55 | //========================================================================= 56 | 57 | //===== NOP 58 | void sngNOP() 59 | { 60 | cycles = 2; 61 | } 62 | 63 | //===== NORMAL 64 | void sngNORMAL() 65 | { 66 | //Not supported 67 | cycles = 4; 68 | } 69 | 70 | //===== PUSH SR 71 | void sngPUSHSR() 72 | { 73 | push16(sr); 74 | cycles = 4; 75 | } 76 | 77 | //===== POP SR 78 | void sngPOPSR() 79 | { 80 | sr = pop16(); changedSP(); 81 | cycles = 6; 82 | } 83 | 84 | //===== MAX 85 | void sngMAX() 86 | { 87 | //Not supported 88 | cycles = 4; 89 | } 90 | 91 | //===== HALT 92 | void sngHALT() 93 | { 94 | system_message("CPU halt requested and ignored.\nPlease send me a saved state."); 95 | cycles = 8; 96 | } 97 | 98 | //===== EI #3 99 | void sngEI() 100 | { 101 | setStatusIFF(FETCH8); 102 | cycles = 5; 103 | } 104 | 105 | //===== RETI 106 | void sngRETI() 107 | { 108 | _u16 temp = pop16(); 109 | pc = pop32(); 110 | sr = temp; changedSP(); 111 | cycles = 12; 112 | } 113 | 114 | //===== LD (n), n 115 | void sngLD8_8() 116 | { 117 | _u8 dst = FETCH8; 118 | _u8 src = FETCH8; 119 | storeB(dst, src); 120 | cycles = 5; 121 | } 122 | 123 | //===== PUSH n 124 | void sngPUSH8() 125 | { 126 | _u8 data = FETCH8; 127 | push8(data); 128 | cycles = 4; 129 | } 130 | 131 | //===== LD (n), nn 132 | void sngLD8_16() 133 | { 134 | _u8 dst = FETCH8; 135 | _u16 src = fetch16(); 136 | storeW(dst, src); 137 | cycles = 6; 138 | } 139 | 140 | //===== PUSH nn 141 | void sngPUSH16() 142 | { 143 | push16(fetch16()); 144 | cycles = 5; 145 | } 146 | 147 | //===== INCF 148 | void sngINCF() 149 | { 150 | setStatusRFP(((sr & 0x300) >> 8) + 1); 151 | cycles = 2; 152 | } 153 | 154 | //===== DECF 155 | void sngDECF() 156 | { 157 | setStatusRFP(((sr & 0x300) >> 8) - 1); 158 | cycles = 2; 159 | } 160 | 161 | //===== RET condition 162 | void sngRET() 163 | { 164 | pc = pop32(); 165 | cycles = 9; 166 | } 167 | 168 | //===== RETD dd 169 | void sngRETD() 170 | { 171 | _s16 d = (_s16)fetch16(); 172 | pc = pop32(); 173 | REGXSP += d; 174 | cycles = 9; 175 | } 176 | 177 | //===== RCF 178 | void sngRCF() 179 | { 180 | SETFLAG_N0; 181 | SETFLAG_V0; 182 | SETFLAG_C0; 183 | cycles = 2; 184 | } 185 | 186 | //===== SCF 187 | void sngSCF() 188 | { 189 | SETFLAG_H0; 190 | SETFLAG_N0; 191 | SETFLAG_C1; 192 | cycles = 2; 193 | } 194 | 195 | //===== CCF 196 | void sngCCF() 197 | { 198 | SETFLAG_N0; 199 | SETFLAG_C(!FLAG_C); 200 | cycles = 2; 201 | } 202 | 203 | //===== ZCF 204 | void sngZCF() 205 | { 206 | SETFLAG_N0; 207 | SETFLAG_C(!FLAG_Z); 208 | cycles = 2; 209 | } 210 | 211 | //===== PUSH A 212 | void sngPUSHA() 213 | { 214 | push8(REGA); 215 | cycles = 3; 216 | } 217 | 218 | //===== POP A 219 | void sngPOPA() 220 | { 221 | REGA = pop8(); 222 | cycles = 4; 223 | } 224 | 225 | //===== EX F,F' 226 | void sngEX() 227 | { 228 | _u8 f = sr & 0xFF; 229 | sr = (sr & 0xFF00) | f_dash; 230 | f_dash = f; 231 | cycles = 2; 232 | } 233 | 234 | //===== LDF #3 235 | void sngLDF() 236 | { 237 | setStatusRFP(FETCH8); 238 | cycles = 2; 239 | } 240 | 241 | //===== PUSH F 242 | void sngPUSHF() 243 | { 244 | push8(sr & 0xFF); 245 | cycles = 3; 246 | } 247 | 248 | //===== POP F 249 | void sngPOPF() 250 | { 251 | sr = (sr & 0xFF00) | pop8(); 252 | cycles = 4; 253 | } 254 | 255 | //===== JP nn 256 | void sngJP16() 257 | { 258 | pc = fetch16(); 259 | cycles = 7; 260 | } 261 | 262 | //===== JP nnn 263 | void sngJP24() 264 | { 265 | pc = fetch24(); 266 | cycles = 7; 267 | } 268 | 269 | //===== CALL #16 270 | void sngCALL16() 271 | { 272 | _u32 target = fetch16(); 273 | push32(pc); 274 | pc = target; 275 | cycles = 12; 276 | } 277 | 278 | //===== CALL #24 279 | void sngCALL24() 280 | { 281 | _u32 target = fetch24(); 282 | push32(pc); 283 | pc = target; 284 | cycles = 12; 285 | } 286 | 287 | //===== CALR $+3+d16 288 | void sngCALR() 289 | { 290 | _u32 target = (_s16)fetch16() + pc; 291 | push32(pc); 292 | pc = target; 293 | cycles = 12; 294 | } 295 | 296 | //===== LD R, n 297 | void sngLDB() 298 | { 299 | regB(first & 7) = FETCH8; 300 | cycles = 2; 301 | } 302 | 303 | //===== PUSH RR 304 | void sngPUSHW() 305 | { 306 | push16(regW(first & 7)); 307 | cycles = 3; 308 | } 309 | 310 | //===== LD RR, nn 311 | void sngLDW() 312 | { 313 | regW(first & 7) = fetch16(); 314 | cycles = 3; 315 | } 316 | 317 | //===== PUSH XRR 318 | void sngPUSHL() 319 | { 320 | push32(regL(first & 7)); 321 | cycles = 5; 322 | } 323 | 324 | //===== LD XRR, nnnn 325 | void sngLDL() 326 | { 327 | regL(first & 7) = fetch32(); 328 | cycles = 5; 329 | } 330 | 331 | //===== POP RR 332 | void sngPOPW() 333 | { 334 | regW(first & 7) = pop16(); 335 | cycles = 4; 336 | } 337 | 338 | //===== POP XRR 339 | void sngPOPL() 340 | { 341 | regL(first & 7) = pop32(); 342 | cycles = 6; 343 | } 344 | 345 | //===== JR cc,PC + d 346 | void sngJR() 347 | { 348 | if (conditionCode(first & 0xF)) 349 | { 350 | cycles = 8; 351 | pc = (_s8)FETCH8 + pc; 352 | } 353 | else 354 | { 355 | cycles = 4; 356 | FETCH8; 357 | } 358 | } 359 | 360 | //===== JR cc,PC + dd 361 | void sngJRL() 362 | { 363 | if (conditionCode(first & 0xF)) 364 | { 365 | cycles = 8; 366 | pc = (_s16)fetch16() + pc; 367 | } 368 | else 369 | { 370 | cycles = 4; 371 | fetch16(); 372 | } 373 | } 374 | 375 | //===== LDX dst,src 376 | void sngLDX() 377 | { 378 | _u8 dst, src; 379 | 380 | FETCH8; //00 381 | dst = FETCH8; //#8 382 | FETCH8; //00 383 | src = FETCH8; //# 384 | FETCH8; //00 385 | 386 | storeB(dst, src); 387 | cycles = 9; 388 | } 389 | 390 | //===== SWI num 391 | void sngSWI() 392 | { 393 | cycles = 16; 394 | 395 | switch(first & 7) 396 | { 397 | //System Call 398 | case 1: push32(pc); 399 | pc = loadL(0xFFFE00 + (rCodeB(0x31) << 2)); 400 | break; 401 | 402 | case 3: interrupt(0); //SWI 3 403 | break; 404 | 405 | case 4: interrupt(1); //SWI 4 406 | break; 407 | 408 | case 5: interrupt(2); //SWI 5 409 | break; 410 | 411 | case 6: interrupt(3); //SWI 6 412 | break; 413 | 414 | default: instruction_error("SWI %d is not valid.", first & 7); 415 | break; 416 | } 417 | } 418 | 419 | //============================================================================= 420 | --------------------------------------------------------------------------------