├── .github └── workflows │ └── test.yaml ├── .gitignore ├── DATA ├── GFX │ └── font8.GEN └── MUSIC │ ├── prueba.pt3 │ └── use_this_directory_for_music.txt ├── GAME.ASM ├── GAMEmotor.GEN ├── GAMEtimer.GEN ├── LIB ├── BIN2BCD.GEN ├── CHECKMSX2.GEN ├── CIN.GEN ├── CLRSCR.GEN ├── CLRSCR5.GEN ├── CLRSCR_SLI.GEN ├── COLORBR.GEN ├── COMVDP.GEN ├── CONSOLE.GEN ├── DU.GEN ├── FIRE_SCN.GEN ├── GETCURSORS.GEN ├── GETGFX.GEN ├── GETJOY.GEN ├── GETJOYMEGA3.GEN ├── GETJOYMEGA6.GEN ├── GETWASD.GEN ├── IPBVRM.GEN ├── IPBVRS.GEN ├── IPBVRSALTER.GEN ├── IRBVRM.GEN ├── IWBVRM.GEN ├── IWBVRMRLE.GEN ├── IWBVRMRLE2.GEN ├── KEY2JOY.GEN ├── LOADGFX.GEN ├── LOADSC5.GEN ├── MACROSVDP.ASM ├── MEGAROM.GEN ├── MINIPSG.GEN ├── MIRATECLA.GEN ├── MOUSE.GEN ├── MSX2_PUTPAL.GEN ├── MSX2_SCREEN.GEN ├── MSX2_SPRTLDPOS.GEN ├── MSX2_SPRTLDPOS_FROMBANK.GEN ├── MULT.GEN ├── N162ASC.GEN ├── N2ASCII.GEN ├── PLY42RUT.GEN ├── PSGMUTE.GEN ├── PT3PLAYER.GEN ├── PUTGFX.GEN ├── PUTGFX_TILETRANS.GEN ├── RANDOM.GEN ├── SCREEN.GEN ├── SET48K.GEN ├── SETPAGEVIEW.GEN ├── SLIDERI.GEN ├── SLOT3ROM.GEN ├── SOUND.GEN ├── SPRITES.GEN ├── SPRITES2.GEN ├── SPRT16HFLIP.GEN ├── SPRT2COL.GEN ├── SPRTLD.GEN ├── SPRTLDPOS.GEN ├── TECLA.GEN ├── TIMERS.GEN ├── TTREPLAY.GEN ├── TTREPLAYDAT.GEN ├── TTSCCDETECT.GEN ├── TTvoltable_combined.bin ├── VNOTAS.GEN └── _EQUS_.GEN ├── LICENSE ├── RAM ├── CONTROL.RAM ├── GAME.RAM ├── PLY42RUT.RAM ├── PT3PLAYER.RAM ├── SET48K.RAM ├── TIMER.RAM ├── TTREPLAY.RAM ├── VIDEO.RAM └── VIDEO_MSX2.RAM ├── README.md ├── RENAME.BAT ├── SRC └── MACROS.ASM └── UPDATES.TXT /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Download asMSX 15 | uses: duhow/download-github-release-assets@v1.1.0 16 | with: 17 | repository: Fubukimaru/asMSX 18 | tag: 1.0.1 19 | files: asmsx-linux-x86_64.zip 20 | - name: Setup asMSX 21 | run: | 22 | unzip asmsx-*.zip 23 | chmod a+x asmsx 24 | - name: Build 25 | run: ./asmsx GAME.ASM 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*.exe 2 | *.sym 3 | *.rom 4 | *.z80 5 | *.0 6 | *.1 7 | ~tmppre.? 8 | -------------------------------------------------------------------------------- /DATA/GFX/font8.GEN: -------------------------------------------------------------------------------- 1 | ; Tiles range: 32 to 95 2 | ; Size= 512 3 | FONT8: 4 | DB $00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$18,$18,$18,$00,$18,$00 5 | DB $6C,$6C,$00,$00,$00,$00,$00,$00,$00,$28,$7C,$28,$7C,$28,$00,$00 6 | DB $10,$7C,$D0,$7C,$16,$7C,$10,$00,$00,$00,$66,$6C,$18,$36,$66,$00 7 | DB $00,$38,$64,$39,$66,$67,$3D,$00,$18,$30,$00,$00,$00,$00,$00,$00 8 | DB $06,$0C,$18,$18,$18,$0C,$06,$00,$30,$18,$0C,$0C,$0C,$18,$30,$00 9 | DB $00,$54,$38,$7C,$38,$54,$00,$00,$00,$18,$18,$7E,$18,$18,$00,$00 10 | DB $00,$00,$00,$00,$00,$30,$30,$20,$00,$00,$7E,$7E,$7E,$00,$00,$00 11 | DB $00,$00,$00,$00,$00,$30,$30,$00,$00,$06,$0C,$18,$30,$60,$C0,$00 12 | DB $7C,$C6,$CE,$D6,$E6,$C6,$7C,$00,$30,$70,$30,$30,$30,$30,$78,$00 13 | DB $FC,$06,$06,$7C,$C0,$C0,$FE,$00,$FC,$06,$06,$7C,$06,$06,$FC,$00 14 | DB $C6,$C6,$C6,$FE,$06,$06,$06,$00,$FE,$C0,$C0,$FC,$06,$06,$FC,$00 15 | DB $7C,$C0,$C0,$FC,$C6,$C6,$7C,$00,$FE,$06,$0C,$18,$30,$30,$30,$00 16 | DB $7C,$C6,$C6,$7C,$C6,$C6,$7C,$00,$7C,$C6,$C6,$7E,$06,$06,$7C,$00 17 | DB $00,$30,$30,$00,$30,$30,$00,$00,$00,$30,$30,$00,$30,$30,$20,$00 18 | DB $02,$06,$0E,$1E,$0E,$06,$02,$00,$00,$00,$78,$00,$78,$00,$00,$00 19 | DB $40,$60,$70,$78,$70,$60,$40,$00,$3C,$66,$06,$0C,$18,$00,$18,$00 20 | DB $7C,$82,$BA,$AA,$BE,$80,$7C,$00,$7C,$C6,$C6,$C6,$FE,$C6,$C6,$00 21 | DB $FC,$C6,$C6,$FC,$C6,$C6,$FC,$00,$7E,$C0,$C0,$C0,$C0,$C0,$7E,$00 22 | DB $FC,$C6,$C6,$C6,$C6,$C6,$FC,$00,$FE,$C0,$C0,$F8,$C0,$C0,$FE,$00 23 | DB $FE,$C0,$C0,$FC,$C0,$C0,$C0,$00,$7E,$C0,$C0,$CE,$C6,$C6,$7E,$00 24 | DB $C6,$C6,$C6,$FE,$C6,$C6,$C6,$00,$78,$30,$30,$30,$30,$30,$78,$00 25 | DB $3C,$18,$18,$18,$18,$D8,$70,$00,$C6,$C6,$CC,$F8,$CC,$C6,$C6,$00 26 | DB $C0,$C0,$C0,$C0,$C0,$C0,$FC,$00,$C6,$EE,$FE,$D6,$C6,$C6,$C6,$00 27 | DB $C6,$E6,$F6,$DE,$CE,$C6,$C6,$00,$7C,$C6,$C6,$C6,$C6,$C6,$7C,$00 28 | DB $FC,$C6,$C6,$C6,$FC,$C0,$C0,$00,$7C,$C6,$C6,$C6,$D6,$CC,$7A,$00 29 | DB $FC,$C6,$C6,$FE,$C4,$C6,$C6,$00,$7E,$C0,$C0,$7C,$06,$06,$FC,$00 30 | DB $FC,$30,$30,$30,$30,$30,$30,$00,$C6,$C6,$C6,$C6,$C6,$C6,$7C,$00 31 | DB $C6,$C6,$C6,$C6,$C6,$6C,$38,$00,$C6,$C6,$C6,$D6,$FE,$EE,$C6,$00 32 | DB $C6,$C6,$6C,$38,$6C,$C6,$C6,$00,$CC,$CC,$CC,$78,$30,$30,$30,$00 33 | DB $FE,$06,$0C,$18,$30,$60,$FE,$00,$0E,$0C,$0C,$0C,$0C,$0C,$0E,$00 34 | DB $00,$C0,$60,$30,$18,$0C,$06,$00,$38,$18,$18,$18,$18,$18,$38,$00 35 | DB $6C,$FE,$FE,$FE,$7C,$38,$10,$00,$00,$00,$00,$00,$00,$00,$7E,$00 36 | 37 | 38 | -------------------------------------------------------------------------------- /DATA/MUSIC/prueba.pt3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/DATA/MUSIC/prueba.pt3 -------------------------------------------------------------------------------- /DATA/MUSIC/use_this_directory_for_music.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/DATA/MUSIC/use_this_directory_for_music.txt -------------------------------------------------------------------------------- /GAME.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------ 2 | ; Plantilla de Joc 48ks No BIOS 3 | ; ZILOG Compatible 4 | ; V2.0 5 | ; Dec 2013-Jul 2019-Gen-2022 6 | ;------------------------------------ 7 | TEST_BORDES= 1 ; Amb nomes que existeixi ja fa les bores de la pantalla al TIMER 8 | USE_SCREEN = 2 9 | FPS_MUSIC = 60 ; 50 o 60 Hz 10 | ;------------------------------------ 11 | ; Dades 12 | ;------------------------------------ 13 | ZILOG 14 | ROM 15 | BIOS 16 | SIZE 48 17 | ;------------------------------------ 18 | ; Constants (No ocupan ROM) 19 | ;------------------------------------ 20 | INCLUDE "LIB/_EQUS_.GEN" 21 | INCLUDE "LIB/VNOTAS.GEN" 22 | ___END_PAGE_0: 23 | 24 | ;------------------------------------ 25 | ; Macros (No ocupan ROM) 26 | ;------------------------------------ 27 | INCLUDE "SRC/MACROS.ASM" 28 | INCLUDE "LIB/MACROSVDP.ASM" 29 | 30 | ;------------------------------------ 31 | ; CONTINGUT PAGINA 0 (Antiga BIOS) 32 | ;------------------------------------ 33 | PAGE 0 34 | db 0 35 | 36 | ORG 38h ; Inici de la rutina de interrupcio 37 | db 0C3h 38 | dw TIMER_R 39 | ;------------------------------------ 40 | ; DADES FIXES (a ROM) PAGE 0 41 | ;------------------------------------ 42 | ; Pantalles 43 | ; GFX 44 | ; Datas 45 | 46 | ;------------------------------------ 47 | ; PAGE 1 48 | ;------------------------------------ 49 | PAGE 1 50 | ; CAPCELERA MANUAL per una ROM 51 | db 41h,42h 52 | dw JOC 53 | db "GAME" 54 | 55 | ;------------------------------------ 56 | ; PROGRAMA - Inicialitzacio 57 | ;------------------------------------ 58 | INCLUDE "LIB/SET48K.GEN" 59 | ;Librerias de Saphire y Ramones para situar los 48Ks ROM seguidos. 60 | 61 | JOC: 62 | ei 63 | halt ; Frame de espera per sincro. Ultima pasada per BIOS 64 | di 65 | ;Neteja RAM 66 | ;bytes a posar a zero OJU! Variables de BIOS!(F37F->FFFF) 67 | m_CLEAR_ZERO 0C000h,0F37Fh 68 | ld SP,PILA 69 | 70 | ; Screen 2,Sprites de 16x16 71 | ld A,USE_SCREEN 72 | call SCREEN 73 | di 74 | ; Posiciona la ROM de 48ks 75 | call SET48K 76 | ; Desactivacio del CLICK CLICK 77 | xor A 78 | ld (0F3DBh),A 79 | 80 | ; Inicialitzacio del TIMER 81 | ; No es fa el posicionar la Rutina de TIMER_R 82 | ; pq ho fem per ROM adalt. 83 | ; Nomes inicia TIMER_T 84 | call TIMER_S ; !!!!(dins fa ei)!!!!! 85 | 86 | RESTARTGAME: 87 | ; Preparo valors inicials del programa 88 | ; LIMPIO SPRITES 89 | ld A,0 ; Sprite DUMMY 90 | ld IX,SPRRAM 91 | call SPRT_INI ; Inicia Buffer Sprites RAM 92 | call PT3_STOP ; Para i prepara player PT3 93 | call TIMERINI ; Inicialitzacio dels TIMERS 94 | ; NETEJA BUFFER DE VIDEO 95 | call SCREEN_OFF 96 | ld A,1 97 | ld (VBUFF_UPDATE),A ; Marco para que se actualice VRAM 98 | ei 99 | halt ; Pasa 1 frame per actualitzar VRAM 100 | di 101 | 102 | INIJOC: 103 | ; DETECTA SI HI HA RATOLI, Sino emula CURSOR per Joystick 104 | ;call MOUSE_IS 105 | ; Inicialitzacio del RATOLI 106 | ;call MOUSEINI 107 | ; Inicialització de Variables del joc 108 | call GAMEINI 109 | ei 110 | 111 | ;------------------------------------ 112 | ; PROGRAMA - MAIN 113 | ;------------------------------------ 114 | MAIN: 115 | halt 116 | call MIRATECLA 117 | cp 27 ; Surto del PRG si pulsen ESC 118 | jp z,FIN 119 | 120 | call GAMEMOTOR 121 | 122 | ld A,(TIM_SPC) ; Control de Colisio de SPRITE 123 | cp 1 124 | call z,SPRTCOL 125 | jp MAIN 126 | 127 | ;------------------------------------ 128 | ; PROGRAMA - Final de Programa 129 | ;------------------------------------ 130 | 131 | FIN: 132 | di 133 | call PT3_STOP 134 | jp RESTARTGAME 135 | 136 | ;------------------------------------ 137 | ; RUTINES - LIBRERIES 138 | ;------------------------------------ 139 | ; Poso cada funcio per separat aixi poso i trec la q uso i la que no 140 | ; Hi ha moltes mes rutines a LIB/ ! 141 | 142 | INCLUDE "LIB/CLRSCR.GEN" 143 | ; Borra Buffer amb un Tile determinat 144 | INCLUDE "LIB/COLORBR.GEN" 145 | ; Canvia el color del Borde 146 | INCLUDE "LIB/GETCURSORS.GEN" 147 | ; Agafa els valors dels cursors + espai + M + Graph 148 | INCLUDE "LIB/GETJOY.GEN" 149 | ; Agafa els valors del joystick especificat a A 150 | INCLUDE "LIB/IPBVRSALTER.GEN" 151 | ; VOLCA buffer Sprite de 128 bytes A VRAM screen 1,2,3 152 | INCLUDE "LIB/IWBVRM.GEN" 153 | ; VOLCA B blocs de 8 bytes desde direccio RAM HL a la direccio VRAM DE 154 | INCLUDE "LIB/MINIPSG.GEN" 155 | ; Mini libreria para hacer efectos con el PSG 156 | INCLUDE "LIB/MIRATECLA.GEN" 157 | ; Control de teclat. Pasa de teclat a codi ascii 158 | ; RAM: CONTROL.RAM 159 | INCLUDE "LIB/PSGMUTE.GEN" 160 | ; Apaga PSG 161 | INCLUDE "LIB/PT3PLAYER.GEN" 162 | ; Player PT3 163 | ; RAM: PT3PLAYER.RAM 164 | INCLUDE "LIB/SCREEN.GEN" 165 | ; Posa Screen 2 i mode de Sprites 16 no ampliat 166 | INCLUDE "LIB/SPRITES.GEN" 167 | ; Contiene dues rutinas 168 | ; SPRT_INI : Inicialitza la taula RAM de SPRITES 169 | ; PUTSPRT : PUT SPRiTe com el de Basic a RAM SPRRAM 170 | ; RAM: VIDEO.RAM 171 | INCLUDE "LIB/SPRTLD.GEN" 172 | ; SPRiTes pattern LoaD a VRAM 173 | INCLUDE "LIB/TECLA.GEN" 174 | ; VOLCA l'estat del teclat (10bytes) a RAM TECLAT 175 | ; RAM: CONTROL.RAM 176 | INCLUDE "LIB/TIMERS.GEN" 177 | ; Control de timers y resets 178 | ; RAM: TIMER.RAM 179 | ;------------------------------------------------ 180 | ; MOTOR I TIMER 181 | ;------------------------------------------------ 182 | INCLUDE "GAMEmotor.GEN" 183 | INCLUDE "GAMEtimer.GEN" 184 | ; RAM: TIMER.RAM 185 | 186 | ;------------------------------------ 187 | ; DADES FIXES (a ROM) 188 | ;------------------------------------ 189 | ; Pantalles 190 | ; GFX 191 | ; Datas 192 | MUSIC_PT3: 193 | ; MUSIC 194 | INCBIN "DATA/MUSIC/prueba.pt3" 195 | ___END_PAGE_2: 196 | ;------------------------------------ 197 | ; Variables : RAM 198 | ;------------------------------------ 199 | PAGE 3 ; RAM DADES 200 | ;.ORG 0E000h ; Si es para 8ks, no comença a Page3, sino per el mig. 201 | ___RAM___: 202 | PILA0: 203 | ds 256 204 | PILA: .byte 205 | ; De SISTEMA 206 | INCLUDE "RAM/CONTROL.RAM" 207 | INCLUDE "RAM/PT3PLAYER.RAM" 208 | INCLUDE "RAM/SET48K.RAM" 209 | INCLUDE "RAM/TIMER.RAM" 210 | INCLUDE "RAM/VIDEO.RAM" 211 | 212 | ; De JOC en si 213 | INCLUDE "RAM/GAME.RAM" 214 | ___END_RAM: 215 | 216 | ;------------------------------------ 217 | ; Informe en TEXTO 218 | ;------------------------------------ 219 | PRINTTEXT "------------------------------------" 220 | PRINTTEXT "* PAGE 0 (Under BIOS) [Max 16384]:" 221 | PRINTTEXT " - USE:" 222 | PRINT ___END_PAGE_0 223 | PRINTTEXT " - LEFT:" 224 | PRINT 04000h - ___END_PAGE_0 225 | PRINTTEXT "------------------------------------" 226 | PRINTTEXT "* PAGE 1-2 (Main code) [Max 32768]:" 227 | PRINTTEXT " - USE:" 228 | PRINT ___END_PAGE_2 - 04000h 229 | PRINTTEXT " - LEFT:" 230 | PRINT 0C000h - ___END_PAGE_2 231 | PRINTTEXT "------------------------------------" 232 | PRINTTEXT "* RAM [Max 16384]:" 233 | PRINTTEXT " - USE:" 234 | PRINT ___END_RAM - ___RAM___ 235 | PRINTTEXT " - LEFT:" 236 | PRINT 0FFFFh - ___END_RAM 237 | PRINTTEXT "------------------------------------" 238 | PRINTTEXT "* TOTAL ROM Bytes Used" 239 | PRINT ___END_PAGE_0 + [___END_PAGE_2 - 04000h] 240 | PRINTTEXT "------------------------------------" 241 | -------------------------------------------------------------------------------- /GAMEmotor.GEN: -------------------------------------------------------------------------------- 1 | ;;MOTOR DEL JOC 2 | ; //////////////////////////////// 3 | ; ///////// GAMEMOTOR //////////// 4 | ; //////////////////////////////// 5 | GAMEMOTOR: 6 | ; POSA EL TEU CODI AQUI 7 | 8 | ret 9 | 10 | 11 | ; //////////////////////////////// 12 | ; ///////// GAMEINI ////////////// 13 | ; //////////////////////////////// 14 | ; Inicialitzacio de Variables del joc 15 | GAMEINI: 16 | ; Posa color negre al borde 17 | ld A,1 18 | call COLORBR 19 | 20 | ld A,1 21 | ld (PT3_NUMSONG),A 22 | xor A 23 | ld (PT3_SECOND),A 24 | ld (PT3_FRAME),A 25 | ld (PT3_PATTERN_POS),A 26 | 27 | ld hl,MUSIC_PT3 28 | call PT3_SELECTMUSIC 29 | 30 | call PT3_START 31 | 32 | ret 33 | 34 | 35 | ;------------------------------------ 36 | ; SUB RUTINES 37 | ;------------------------------------ 38 | 39 | ; //////////////////////////////// 40 | ; ///////// SPRTCOL ////////////// 41 | ; //////////////////////////////// 42 | ; Sprite colision 43 | ; Similar al ON SPRITE GOSUB del BASIC 44 | SPRTCOL: 45 | ;***** Activar Control Temps Timer *** 46 | IFDEF TEST_BORDES 47 | ld A,6 48 | call COLORBR 49 | ENDIF 50 | ;************************************* 51 | di ; CAL UN DISABLE INTERRUP MENTRES ES COMPROBA 52 | 53 | 54 | SPRTCOLEND: 55 | xor A 56 | ld (TIM_SPC),A 57 | ;***** Activar Control Temps Timer *** 58 | IFDEF TEST_BORDES 59 | ld A,1 60 | call COLORBR 61 | ENDIF 62 | ;************************************* 63 | ei 64 | ret 65 | 66 | 67 | ; //////////////////////////////// 68 | ; /// MOTOR_TIMER_SPECIAL //////// 69 | ; //////////////////////////////// 70 | ; Rutinas y cosas especiales que han de pasar en cada frame 71 | ; propias del juego en especifico 72 | MOTOR_TIMER_SPECIAL: 73 | 74 | .END: 75 | ret 76 | -------------------------------------------------------------------------------- /GAMEtimer.GEN: -------------------------------------------------------------------------------- 1 | ;----------------- 2 | ; rutina timer 3 | ;----------------- 4 | 5 | ;/// Configura el timer per que apunti a la nostre rutina NO BIOS VERSION /// 6 | TIMER_S: 7 | xor A 8 | ld (TIMER_T),A 9 | ret 10 | 11 | TIMER_R: 12 | push AF 13 | push BC 14 | push DE 15 | push HL 16 | push IX 17 | push IY 18 | 19 | in A,(99h) ; acknowledge? 20 | ; Al no tener BIOS este "in" fa RESET de EI. 21 | ; perque no torni a entrar. 22 | ; Lectura de SPRITE COLISION 23 | and 00100000b 24 | srl A 25 | srl A 26 | srl A 27 | srl A 28 | srl A 29 | ld (TIM_SPC),A 30 | 31 | ;***** Activar Control Temps Timer *** 32 | IFDEF TEST_BORDES 33 | ld A,2 34 | call COLORBR 35 | ENDIF 36 | ;************************************* 37 | ;******** Aqui va la rutina ******** 38 | ld HL,TIMER_T 39 | inc (HL) ;incrementa contador 40 | call TIMERUPDATE 41 | 42 | call MOTOR_TIMER_SPECIAL 43 | 44 | ;***** Activar Control Temps Timer *** 45 | IFDEF TEST_BORDES 46 | ld A,13 47 | call COLORBR 48 | ENDIF 49 | ;************************************* 50 | 51 | ld HL,SPRRAM 52 | call IPBVRSALTER ;volca buffer Sprite a VRAM amb ALTERNANCIA 53 | 54 | ;***** Activar Control Temps Timer *** 55 | IFDEF TEST_BORDES 56 | ld A,11 57 | call COLORBR 58 | ENDIF 59 | ;************************************* 60 | ld A,(VBUFF_UPDATE) 61 | or A 62 | jr z,.NEXT ; Solo se actualiza si VBUFF_UPDATE != 0 63 | xor A 64 | ld (VBUFF_UPDATE),A 65 | ld HL,VBUFF 66 | ld DE,VRM_MAP 67 | ld B,96 68 | call IWBVRM ;volca buffer a VRAM 69 | .NEXT: 70 | ;***** Activar Control Temps Timer *** 71 | IFDEF TEST_BORDES 72 | ld A,7 73 | call COLORBR 74 | ENDIF 75 | ;************************************* 76 | 77 | call TECLA ;refresca array de teclat 78 | ld HL,JOY1 79 | xor A 80 | call GETJOY ;refresca Joystick 1 81 | ld HL,CURSORS 82 | xor A 83 | call GETCURSORS ;refresca Cursors 84 | ld A,(JOY1) 85 | ld HL,CURSORS 86 | or (HL) ;fusio de cursors+joystick 1 87 | ld (PLY1CONTROL),A 88 | ;call GETMOUSE 89 | 90 | ;***** Activar Control Temps Timer *** 91 | ;IFDEF TEST_BORDES 92 | ; ld A,9 93 | ; call COLORBR 94 | ;ENDIF 95 | ;************************************* 96 | 97 | ;Toca musica o FX 98 | ld A,TIMER_MINIPSG 99 | call TIMERCHECK 100 | jr z,.PLAYER_FULL 101 | 102 | ld A,(PT3_ON) 103 | or A 104 | jr Z,.END_PLAYER_TIMER_CONTROL 105 | call PT3_PLAY ; Calcula como ande estar los valores del PSG en el Frame 106 | jr .END_PLAYER_TIMER_CONTROL 107 | 108 | .PLAYER_FULL: 109 | ld A,(PT3_ON) 110 | or A 111 | jr Z,.END_PLAYER_TIMER_CONTROL 112 | call PT3_PLAY ; Calcula como ande estar los valores del PSG en el Frame 113 | call PT3_ROUT ; pasa los valores que han de sonarl al PSG 114 | 115 | .END_PLAYER_TIMER_CONTROL: 116 | ; Suma de frames y segundos 117 | ld A,(PT3_FRAME) 118 | inc A 119 | ld (PT3_FRAME),A 120 | cp FPS_MUSIC 121 | jr c,.END_FRAME_SECOND_CONTROL 122 | xor A 123 | ld (PT3_FRAME),A 124 | ld A,(PT3_SECOND) 125 | inc A 126 | ld (PT3_SECOND),A 127 | .END_FRAME_SECOND_CONTROL: 128 | 129 | ;*********************************** 130 | ;***** Desctivar Control Temps Timer *** 131 | IFDEF TEST_BORDES 132 | ld A,1 133 | call COLORBR 134 | ENDIF 135 | ;******************************** 136 | 137 | pop IY 138 | pop IX 139 | pop HL 140 | pop DE 141 | pop BC 142 | pop AF 143 | 144 | ei 145 | ;ret ; [32ks o Megarom] Torna amb RET perque hi ha BIOS i s'enganxa a 0FD9Fh 146 | reti ; [>48ks] No hi ha bios cal fer reti. 147 | -------------------------------------------------------------------------------- /LIB/BIN2BCD.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// BIN2BCD ////////////// 3 | ; //////////////////////////////// 4 | ; Pasa un numero binari del 0 al 99 a formato BCD 5 | ; a(BIN) => a(BCD) 6 | ; [0..99] => [00h..99h] 7 | 8 | ; A = Numero a convertir 9 | 10 | ; Cal RAM : res 11 | ; Toca : res 12 | ; Retorna : A = Numero BCD 13 | ; Usa fun.: res 14 | 15 | BIN2BCD: 16 | push BC 17 | ld C,A 18 | ld B,8 19 | xor A 20 | .LOOP: 21 | sla C 22 | adc A,A 23 | daa 24 | djnz .LOOP 25 | pop BC 26 | ret 27 | -------------------------------------------------------------------------------- /LIB/CHECKMSX2.GEN: -------------------------------------------------------------------------------- 1 | ; /////////////////////////// 2 | ; ///////// CHECKMSX2 ////// 3 | ; /////////////////////////// 4 | 5 | ; Test si es un MSX2 o no, i ho guarda a RAM ISAMSX2 6 | ; Ha d'estar a page 1 per fer-ho primer de tot. 7 | ; CAL BIOS !! 8 | 9 | ; Cal RAM : MSXID [VIDEO_MSX2.RAM] 10 | ; Toca : res 11 | ; Retorna : A MSXID [1=MSX2 o superior 0=MSX] 12 | ; Usa fun.: res 13 | 14 | CHECKMSX2: 15 | ld A,(002Dh) ; Posicio BIOS on hi ha el tipus de MSX 16 | or A 17 | jp z,.NOMSX2 18 | ld A,1 19 | .NOMSX2: 20 | ld (MSXID),A 21 | ret 22 | 23 | ISAMSX2: 24 | ld A,(MSXID) 25 | or A 26 | ret 27 | -------------------------------------------------------------------------------- /LIB/CIN.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/CIN.GEN -------------------------------------------------------------------------------- /LIB/CLRSCR.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// CLRSCR /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Borra Buffer amb un Tile determinat 6 | 7 | ; D = Tile a posar 8 | ; HL = Punter del Buffer 9 | 10 | ; Cal RAM : res 11 | ; Toca : BC 12 | ; Retorna : res 13 | ; Usa fun.: res 14 | 15 | CLRSCR: 16 | ld BC,768 17 | .LOOP4: 18 | ld A,D 19 | ld (HL),A 20 | dec BC 21 | inc HL 22 | xor A 23 | cp B 24 | jr nz,.LOOP4 25 | cp C 26 | jr nz,.LOOP4 27 | 28 | ret 29 | -------------------------------------------------------------------------------- /LIB/CLRSCR5.GEN: -------------------------------------------------------------------------------- 1 | ; ////////////////////////////// 2 | ; ///////// CLRSCR5 //////////// 3 | ; ////////////////////////////// 4 | 5 | ; Omple la pagina pantalla amb un color 6 | ; COMPTE ! deja EI activat al marxar! 7 | 8 | ; A = Pagina a omplir 9 | ; B = Color 10 | 11 | ; Cal RAM : VDPCOMDATA 12 | ; Toca : C,IX,HL 13 | ; Retorna : res 14 | ; Usa fun.: _VDPCMD 15 | 16 | CLRSCR5: 17 | ; Copy Titulo-Logo 18 | ld IX,VDPCOMDATA 19 | ;ld (IX+0),0 ;SXL No es fa servir 20 | ;ld (IX+1),0 ;SXH No es fa servir 21 | ;ld (IX+2),0 ;SYL No es fa servir 22 | ;ld (IX+3),0 ;SYH No es fa servir 23 | ld (IX+4),0 ;DXL Tota la pantalla Origen 24 | ld (IX+5),0 ;DXH Per aquest cas SEMPRE 0 25 | ld (IX+6),0 ;DYL Tota la pantalla Origen 26 | ld (IX+7),A ;DYH Page ve per A 27 | ld (IX+8),0 ;INCXL Tota la pantalla 28 | ld (IX+9),1 ;INCXH Per aquest cas SEMPRE 1 = 256 pixeles 29 | ld (IX+10),MAXY_SCREEN ;INCYL Tota la pantalla 30 | ld (IX+11),0 ;INCYH Per aquest cas SEMPRE 0 31 | ld (IX+12),B ;COLO ve per B 32 | ld (IX+13),0 ;ARG Per aquest cas SEMPRE 0 33 | ld (IX+14),CMDRECT ;CMD LMMV Fill Rectangle 34 | ld HL,VDPCOMDATA ; Envio CMD a fer 35 | call _VDPCMD 36 | ret 37 | -------------------------------------------------------------------------------- /LIB/CLRSCR_SLI.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// CLRSCR_SLI /////////// 3 | ; //////////////////////////////// 4 | 5 | ; Borra Buffer Cortinilla SLIDERI con tile 0 6 | 7 | ; Cal RAM : VBUFF 8 | ; Toca : BC,DE,HL i de SLIDERI 9 | ; Retorna : res 10 | ; Usa fun.: SLIDERI 11 | 12 | CLRSCR_SLI: 13 | ; Clear Screen con cortinilla 14 | xor A 15 | ld DE,0 16 | ld BC,32*256+24 17 | ld HL,VBUFF 18 | call SLIDERI 19 | ret 20 | -------------------------------------------------------------------------------- /LIB/COLORBR.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// COLORBR ////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Canvia el color de les bores 6 | 7 | ; A = Color a posar 8 | 9 | ; Cal RAM : res 10 | ; Toca : res 11 | ; Retorna : res 12 | ; Usa fun.: res 13 | 14 | COLORBR: 15 | m_WRITE_DATA_REGISTER 07h ; Register 7: colour register. 16 | ret 17 | -------------------------------------------------------------------------------- /LIB/COMVDP.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/COMVDP.GEN -------------------------------------------------------------------------------- /LIB/CONSOLE.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ////// CONSOLE PRINT /////////// 3 | ; //////////////////////////////// 4 | 5 | ; Function to print Text in Screen 0 6 | ; Use BIOS - CHPUT 7 | 8 | ; CClearScreen -> Clear Screen and Home Cursor 9 | ; CLocate -> Move Cursor to X,Y Coordinates 10 | ; CPutText -> Write Text (ends with 0) 11 | ; CPutVar -> Write Variable data (00-99) 12 | 13 | CClearScreen: 14 | ld A,27 15 | call CHPUT 16 | ld A,'E' ; Clear Screen 17 | call CHPUT 18 | ld A,27 19 | call CHPUT 20 | ld A,'E' ; Cursor Home 21 | call CHPUT 22 | ret 23 | CEndL: 24 | ld A,10 25 | call CHPUT 26 | ld A,13 27 | call CHPUT 28 | ret 29 | 30 | ; BC = Coordinates Y,X -> (B,C) 31 | CLocate: 32 | push BC 33 | ld A,27 34 | call CHPUT 35 | ld A,'Y' ; Locate 36 | call CHPUT 37 | pop BC 38 | push BC 39 | ld A,B 40 | add A,32 41 | call CHPUT 42 | pop BC 43 | ld A,C 44 | add A,32 45 | call CHPUT 46 | ret 47 | 48 | ; HL = Pointer to Text (end with 0) 49 | CPutText: 50 | .loop: 51 | ld A,(HL) 52 | or A 53 | ret z 54 | call CHPUT 55 | inc HL 56 | jr .loop 57 | 58 | ; A = Data to show 59 | CPutVar: 60 | call N2ASCII 61 | ld A,H 62 | call CHPUT 63 | ld A,L 64 | call CHPUT 65 | ret 66 | -------------------------------------------------------------------------------- /LIB/DU.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/DU.GEN -------------------------------------------------------------------------------- /LIB/FIRE_SCN.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// FIRE_SCN ///////////// 3 | ; //////////////////////////////// 4 | 5 | ; Efecto fuego en Antorchas 16x16 6 | ; 24,25 7 | ; 26,27 8 | 9 | ; HL = Offset del buffer 10 | ; VOLCA buffer Tiles concretes de antorchas [24,25,26,27] 11 | 12 | ; Cal RAM : res 13 | ; Toca : B,C,D,E 14 | ; Retorna : res 15 | ; Usa fun.: res 16 | 17 | FIRE_SCN: 18 | ld A,(TIMER_T) 19 | and 1 20 | cp 1 21 | jp nz,FIRE_SCNEND ; Aixi no es tan rapid 22 | 23 | ld B,5 24 | ld IX,V_TORCHBUFF 25 | xor A 26 | .LOOPZQ1: ; Poso a Zero els 5 primers files de Q1 27 | ld (IX),A 28 | inc IX 29 | djnz .LOOPZQ1 30 | 31 | ld B,5 32 | ld IX,V_TORCHBUFF+8 33 | xor A 34 | .LOOPZQ2: ; Poso a Zero els 5 primers files de Q2 35 | ld (IX),A 36 | inc IX 37 | djnz .LOOPZQ2 38 | 39 | ld B,8 40 | ld IY,V_TORCHBUFF+16+1 41 | ld IX,V_TORCHBUFF+16 42 | .LOOPQ3: ; Offset Q3 43 | ld A,(IY) 44 | ld (IX),A 45 | inc IX 46 | inc IY 47 | djnz .LOOPQ3 48 | ld A,R 49 | ld IX,V_TORCHBUFF+23 50 | ld (IX),A 51 | 52 | ld B,3 53 | ld IY,V_TORCHBUFF+4+1 54 | ld IX,V_TORCHBUFF+4 55 | .LOOPQ1: ; Offset Q1 56 | ld A,(IY) 57 | ld (IX),A 58 | inc IX 59 | inc IY 60 | djnz .LOOPQ1 61 | ld A,(V_TORCHBUFF+16) 62 | ld (IX),A 63 | 64 | ld B,8 65 | ld IY,V_TORCHBUFF+24+1 66 | ld IX,V_TORCHBUFF+24 67 | .LOOPQ4: ; Offset Q4 68 | ld A,(IY) 69 | ld (IX),A 70 | inc IX 71 | inc IY 72 | djnz .LOOPQ4 73 | ld A,R 74 | sla A 75 | sla A 76 | sla A 77 | sla A 78 | ld IX,V_TORCHBUFF+31 79 | ld (IX),A 80 | 81 | ld B,3 82 | ld IY,V_TORCHBUFF+12+1 83 | ld IX,V_TORCHBUFF+12 84 | .LOOPQ2: ; Offset Q2 85 | ld A,(IY) 86 | ld (IX),A 87 | inc IX 88 | inc IY 89 | djnz .LOOPQ2 90 | ld A,(V_TORCHBUFF+24) 91 | ld (IX),A 92 | 93 | ld IX,V_TORCHBUFF+4 ; Mascara Q1 94 | ld A,(IX) 95 | and 00000011b 96 | ld (IX),A 97 | inc IX 98 | ld A,(IX) 99 | and 00000011b 100 | ld (IX),A 101 | inc IX 102 | ld A,(IX) 103 | and 00000111b 104 | ld (IX),A 105 | inc IX 106 | ld A,(IX) 107 | and 00000111b 108 | ld (IX),A 109 | 110 | ld IX,V_TORCHBUFF+12 ; Mascara Q2 111 | ld A,(IX) 112 | and 11000000b 113 | ld (IX),A 114 | inc IX 115 | ld A,(IX) 116 | and 11000000b 117 | ld (IX),A 118 | inc IX 119 | ld A,(IX) 120 | and 11100000b 121 | ld (IX),A 122 | inc IX 123 | ld A,(IX) 124 | and 11100000b 125 | ld (IX),A 126 | 127 | ld IX,V_TORCHBUFF+16 ; Mascara Q3 128 | ld A,(IX) 129 | rrc A 130 | and 00000111b 131 | ld (IX),A 132 | inc IX 133 | ld A,(IX) 134 | and 00000111b 135 | ld (IX),A 136 | inc IX 137 | ld A,(IX) 138 | and 00000111b 139 | ld (IX),A 140 | inc IX 141 | ld A,(IX) 142 | and 00001111b 143 | ld (IX),A 144 | inc IX 145 | ld A,(IX) 146 | xor 0FFh 147 | and 00001111b 148 | ld (IX),A 149 | inc IX 150 | ld A,(IX) 151 | and 00001111b 152 | ld (IX),A 153 | inc IX 154 | ld A,(IX) 155 | and 00001111b 156 | ld (IX),A 157 | inc IX 158 | ld A,(IX) 159 | and 00001111b 160 | ld (IX),A 161 | 162 | ld IX,V_TORCHBUFF+24 ; Mascara Q4 163 | ld A,(IX) 164 | and 11000000b 165 | ld (IX),A 166 | inc IX 167 | ld A,(IX) 168 | and 11000000b 169 | ld (IX),A 170 | inc IX 171 | ld A,(IX) 172 | and 11000000b 173 | ld (IX),A 174 | inc IX 175 | ld A,(IX) 176 | and 11100000b 177 | ld (IX),A 178 | inc IX 179 | ld A,(IX) 180 | and 11100000b 181 | ld (IX),A 182 | inc IX 183 | ld A,(IX) 184 | xor 0FFh 185 | and 11100000b 186 | ld (IX),A 187 | inc IX 188 | ld A,(IX) 189 | and 11100000b 190 | ld (IX),A 191 | inc IX 192 | ld A,(IX) 193 | and 11100000b 194 | ld (IX),A 195 | 196 | ; Fer volcat a VRAM 197 | ld B,4 198 | ld HL,V_TORCHBUFF 199 | ld DE,VRM_PAT+24*8 200 | call IWBVRM 201 | FIRE_SCNEND: 202 | ret 203 | -------------------------------------------------------------------------------- /LIB/GETCURSORS.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////////// 2 | ; ///////// GETCURSORS /////////////// 3 | ; //////////////////////////////////// 4 | 5 | ; Agafa els valors del cursors 6 | 7 | ; HL = Posicio variable CURSORS 8 | 9 | ; Cal RAM : KEYBOARD (CONTROL.RAM) 10 | ; Toca : A,IX 11 | ; Retorna : Posicio (HL) bits 5-0 [B/A/R/L/D/U] per 1 12 | ; Usa fun.: res 13 | ; RAM: KEYBOARD (CONTROL.RAM) 14 | GETCURSORS: 15 | ld IX,KEYBOARD 16 | xor A 17 | 18 | bit 0,(IX+1) 19 | jr nz,.NEXT2 20 | or 00010000b ;Espai Tret A[32] 21 | .NEXT2: 22 | bit 4,(IX+1) 23 | jr nz,.NEXT3 24 | or 00000100b ;CURSOR Esquerra [1] 25 | .NEXT3: 26 | bit 5,(IX+1) 27 | jr nz,.NEXT4 28 | or 00000001b ;CURSOR Amunt [2] 29 | .NEXT4: 30 | bit 6,(IX+1) 31 | jr nz,.NEXT5 32 | or 00000010b ;CURSOR Aball [3] 33 | .NEXT5: 34 | bit 7,(IX+1) 35 | jr nz,.NEXT6 36 | or 00001000b ;CURSOR Dreta [4] 37 | .NEXT6: 38 | bit 2,(IX+3) 39 | jr nz,.NEXT7 40 | or 00100000b ;GRAPH [Alt] Tret B [6] 41 | .NEXT7: 42 | bit 2,(IX+5) 43 | jr nz,.END 44 | or 00100000b ; M Tret B [77] 45 | .END: 46 | ld (HL),A 47 | ret 48 | -------------------------------------------------------------------------------- /LIB/GETGFX.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/GETGFX.GEN -------------------------------------------------------------------------------- /LIB/GETJOY.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// GETJOY /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Agafa els valors del joystick especificat a A 6 | 7 | ; A = 0 Joystick 1 8 | ; 1 Joystick 2 9 | ; HL = Posicio variable joystick 10 | 11 | ; Cal RAM : res 12 | ; Toca : res 13 | ; Retorna : Posicio (HL) bits 5-0 [B/A/R/L/D/U] per 1, copia a A 14 | ; Usa fun.: res 15 | 16 | GETJOY: 17 | or A ; Equivale a CP 0 por flags 18 | jr z,.GETJO1 ;Select 19 | ld B,01000000b ;Select Joy 2 & Rst Pulse 2 20 | jr .GETJ02 21 | .GETJO1: 22 | ld B,00000000b ;Select Joy 1 & Rst Pulse 1 23 | .GETJ02: 24 | ld A,0Fh ;Reg F[15] PSG 25 | out (0A0h),A 26 | in A,(0A2h) ;Leo antes 27 | and 10111111b ;Vacio bit que quiero modificar. 28 | or B 29 | out (0A1h),A ;Select Joy 30 | ld A,0Eh ;Reg E[14] PSG 31 | out (0A0h),A 32 | in A,(0A2h) ;Cojo valores 33 | cpl ;Paso a activos a 1 34 | and 00111111b 35 | ld (HL),A 36 | ret 37 | -------------------------------------------------------------------------------- /LIB/GETJOYMEGA3.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; //////// GETJOYMEGA3 /////////// 3 | ; //////////////////////////////// 4 | 5 | ; Agafa els valors del joystick especificat a A 6 | 7 | ; A = 0 Joystick 1 8 | ; 1 Joystick 2 9 | ; HL = Posicio variable joystick 10 | 11 | ; Cal RAM : res 12 | ; Toca : C,DE 13 | ; Retorna : Posicio (HL) bits 7-0 [START,A,C,B,Rt,Lt,Dn,Up] per 1, copia a A 14 | ; Usa fun.: BIOS -> WRTPSG, RDPSG 15 | 16 | GETJOYMEGA3: 17 | or A ; Equivale a CP 0 por flags 18 | jr z,.GETJO1 ;Select 19 | ld DE,20CFh ; Port 2 20 | jr .GETJ02 21 | .GETJO1: 22 | ld DE,108Fh ; Port 1 23 | .GETJ02: 24 | ld A,15 25 | call WRTPSG 26 | m_RDJOYPORT 27 | and 3Fh 28 | ld C,A ; c=0,0,C,B,Rt,Lt,Dn,Up 29 | m_FLIPPORTOUT 30 | m_RDJOYPORT 31 | and 3Ch 32 | add A,A 33 | add A,A 34 | ld B,A ; b=ST,A,ID1,ID0,0000 35 | m_FLIPPORTOUT 36 | ld A,C ; a=0,0,C,B,Rt,Lt,Dn,Up 37 | or B ; a=ST,A,C,B,Rt,Lt,Dn,Up 38 | cpl 39 | ld (HL),A 40 | ret 41 | -------------------------------------------------------------------------------- /LIB/GETJOYMEGA6.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; //////// GETJOYMEGA6 /////////// 3 | ; //////////////////////////////// 4 | 5 | ; Agafa els valors del joystick especificat a A 6 | 7 | ; A = 0 Joystick 1 8 | ; 1 Joystick 2 9 | ; HL = Posicio variable joystick (ocupa 2 bytes seguits) 10 | 11 | ; Cal RAM : res 12 | ; Toca : BC,DE,HL 13 | ; Retorna : Posicio (HL) 14 | ; byte 0: bits 7-0 [START,A,C,B,Rt,Lt,Dn,Up] per 1, copia a C 15 | ; byte 1: bits 3-0 [MODE,X,Y,Z] per 1, copia a B i A 16 | ; Usa fun.: BIOS -> WRTPSG, RDPSG 17 | 18 | GETJOYMEGA6: 19 | or A ; Equivale a CP 0 por flags 20 | jr z,.GETJO1 ;Select 21 | ld DE,20CFh ; Port 2 22 | jr .GETJ02 23 | .GETJO1: 24 | ld DE,108Fh ; Port 1 25 | .GETJ02: 26 | push HL 27 | ld A,15 28 | call WRTPSG 29 | m_RDJOYPORT 30 | and 3Fh 31 | ld C,A ; c=0,0,C,B,Rt,Lt,Dn,Up 32 | m_FLIPPORTOUT ; Flip Output high 2 33 | m_RDJOYPORT 34 | and 3Ch ; crop ST,A,ID1,ID0 35 | add A,A 36 | add A,A ; a=ST,A,ID1,ID0,0000 37 | and 0C0h ; a=ST,A,0,0,0000 38 | or C ; a=ST,A,C,B,Rt,Lt,Dn,Up 39 | ld C,A ; c=ST,A,C,B,Rt,Lt,Dn,Up 40 | m_FLIPPORTOUT ; Flip Output low 3 41 | m_FLIPPORTOUT ; Flip Output high 4 42 | m_FLIPPORTOUT ; Flip Output low 5 43 | m_FLIPPORTOUT ; Flip Output high 6 44 | m_FLIPPORTOUT ; Flip Output low 7 45 | m_RDJOYPORT 46 | cpl 47 | and 0Fh ; Clear ID and crop MODE,X,Y,Z 48 | ld B,A ; b=0,0,0,0,MODE,X,Y,Z 49 | ; One last pulse to reset the joypad 50 | m_FLIPPORTOUT ; Flip Output high 8 51 | m_FLIPPORTOUT ; Flip Output low 1 52 | ld A,C 53 | cpl 54 | pop HL 55 | ld (HL),A ; byte 0: bits 7-0 [START,A,C,B,Rt,Lt,Dn,Up] per 1 56 | inc HL 57 | ld A,B 58 | ld (HL),A ; byte 1: bits 3-0 [MODE,X,Y,Z] per 1 59 | ret 60 | -------------------------------------------------------------------------------- /LIB/GETWASD.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////////// 2 | ; ///////// GETWASD /////////////// 3 | ; //////////////////////////////////// 4 | 5 | ; Agafa els valors del cursors 6 | 7 | ; HL = Posicio variable CURSORS2 8 | 9 | ; Cal RAM : TECLAT 10 | ; Toca : A,IX 11 | ; Retorna : Posicio (HL) bits 5-0 [B/A/R/L/D/U] per 1 12 | ; Usa fun.: res 13 | 14 | GETWASD: 15 | ld IX,TECLAT 16 | xor A 17 | 18 | bit 3,(IX+2) 19 | jr nz,.NEXT2 20 | or 00010000b ; TAB [11] Buton 1 21 | .NEXT2: 22 | bit 6,(IX+7) 23 | jr nz,.NEXT3 24 | or 00000100b ; Tecla A - ESQUERRA [87] 25 | .NEXT3: 26 | bit 4,(IX+4) 27 | jr nz,.NEXT4 28 | or 00000001b ; Tecla W - AMUNT [65] 29 | .NEXT4: 30 | bit 0,(IX+4) 31 | jr nz,.NEXT5 32 | or 00000010b ; Tecla S - ABALL [83] 33 | .NEXT5: 34 | bit 1,(IX+6) 35 | jr nz,.NEXT6 36 | or 00001000b ;Tecla D - DRETA [68] 37 | .NEXT6: 38 | bit 0,(IX+3) 39 | jr nz,.GETWASDFI 40 | or 00100000b ;GRAPH (Alt) [6] 41 | 42 | .GETWASDFI: 43 | ld (HL),A 44 | ret 45 | -------------------------------------------------------------------------------- /LIB/IPBVRM.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// IPBVRM /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Interrupt pub buffer videoram 6 | ; VOLCA buffer de 768 bytes A VRAM screen2 7 | ; 29/12/04 Arnau Castellvi / Zona Neutra 8 | 9 | ; HL = Offset del buffer 10 | 11 | ; Cal RAM : res 12 | ; Toca : B,C,D,E 13 | ; Retorna : res 14 | ; Usa fun.: res 15 | 16 | IPBVRM: 17 | ld DE,VRM_MAP 18 | ld B,96 19 | ld A,E 20 | out (99h),A 21 | ld A,D 22 | or 40h 23 | out (99h),A 24 | ld C,98h 25 | 26 | IPBVRM0: 27 | ld D,B 28 | outi 29 | nop 30 | nop 31 | nop 32 | outi 33 | nop 34 | nop 35 | nop 36 | outi 37 | nop 38 | nop 39 | nop 40 | outi 41 | nop 42 | nop 43 | nop 44 | outi 45 | nop 46 | nop 47 | nop 48 | outi 49 | nop 50 | nop 51 | nop 52 | outi 53 | nop 54 | nop 55 | ld B,D 56 | outi 57 | jr nz,IPBVRM0 58 | ret 59 | -------------------------------------------------------------------------------- /LIB/IPBVRS.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// IPBVRS /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Interrupt put buffer videoram Sprite 6 | ; VOLCA buffer Sprite de 128 bytes A VRAM screen 1,2,3 7 | ; Suposa VDP a port 98h,99h 8 | ; Basat en IPBVRM 9 | ; CAL cridar amb Interrupcions DESACTIVADES 10 | 11 | ; HL = Offset del buffer 12 | 13 | ; Cal RAM : res 14 | ; Toca : BC,DE 15 | ; Retorna : res 16 | ; Usa fun.: res 17 | 18 | IPBVRS: 19 | ld A,128 ; 128 bytes [32*4] Sprites 20 | ld B,A ; Volcada de atributos de 32 Sprites 21 | 22 | ld DE,VRM_SPA 23 | ld A,E 24 | out (99h),A 25 | ld A,D 26 | or 40h 27 | out (99h),A 28 | ld C,98h 29 | ; Volcat dels SPRITES 30 | .LOOP_OUT: 31 | ld A,(HL) 32 | out (C),A 33 | inc HL 34 | djnz .LOOP_OUT 35 | ret 36 | -------------------------------------------------------------------------------- /LIB/IPBVRSALTER.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// IPBVRS /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Interrupt put buffer videoram Sprite 6 | 7 | ; HL = Offset del buffer 8 | ; VOLCA buffer Sprite de 128 bytes A VRAM screen 1,2,3 9 | ; Basat en IPBVRM 10 | 11 | ; Cal RAM : res 12 | ; Toca : B,C,D,E 13 | ; Retorna : res 14 | ; Usa fun.: res 15 | ; Usa Contantes : SRP_FIJOS de VIDEO.RAM 16 | 17 | IPBVRSALTER: 18 | ld A,32 19 | sla A 20 | sla A 21 | ld B,A ; Volcada de 32 Sprites 22 | ld DE,VRM_SPA ; Prepara els ports per escritura a 23 | ld A,E ; regio de Sprites de VRAM 24 | out (99h),A 25 | ld A,D 26 | or 40h 27 | out (99h),A 28 | ld C,98h ; Port a enviar del VDP [98h] 29 | 30 | ld A,(TIMER_T) 31 | and 1 32 | cp 1 33 | jr z,.INVERSO 34 | 35 | ; De Incremento 36 | ; Volcat dels SPRITES 37 | ;otir 38 | .LOOP_OUT: 39 | ld A,(HL) 40 | out (C),A 41 | inc HL 42 | djnz .LOOP_OUT 43 | ret 44 | ; De decremento 45 | .INVERSO: 46 | ld A,[SPR_FIJOS*4] ; Deja los primeros igual 47 | ld B,A 48 | ;otir 49 | .LOOP_OUT_FIX: 50 | ld A,(HL) 51 | out (C),A 52 | inc HL 53 | djnz .LOOP_OUT_FIX 54 | 55 | ld DE,[[31-SPR_FIJOS]*4] 56 | add HL,DE 57 | ld B,[32-SPR_FIJOS] 58 | .LOOP: 59 | push BC 60 | ld B,4 61 | ;otir ; Volcat de 1 sprite [4bytes] 62 | .LOOP_OUT_INV: 63 | ld A,(HL) 64 | out (C),A 65 | inc HL 66 | djnz .LOOP_OUT_INV 67 | 68 | pop BC 69 | ld DE,-8 ; Tirem enrrera 8 posicion 70 | add HL,DE ; que es l'sprite que acabem de posar 71 | ; i el que volem posar 72 | ; dec HL ; 9 +1 pel otir que resta HL al acabar 73 | djnz .LOOP 74 | IPBVRS_END: 75 | ret 76 | -------------------------------------------------------------------------------- /LIB/IRBVRM.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// IRBVRM /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Read Bloq Video RaM 6 | ; volca B blocs de 8 bytes desde direccio VRAM DE a la direccio RAM HL 7 | ; No utilitza BIOS, desavilita les interupcions 8 | ; 29/12/04 Arnau Castellvi / Zona Neutra 9 | ; 12/08/2018 Rafel Perez /ThePetsmode 10 | 11 | ; B = Blocs de 8 bytes 12 | ; HL = direccio RAM 13 | ; DE = direccion VRAM 14 | 15 | ; Cal RAM : res 16 | ; Toca : A,BC,D 17 | ; Retorna : res 18 | ; Usa fun.: res 19 | 20 | IRBVRM: 21 | ld A,E 22 | out (99h),A 23 | ld A,D 24 | and 00111111b 25 | out (99h),A 26 | ld C,98h 27 | IRBVRM0: 28 | ld D,B 29 | ini 30 | nop 31 | nop 32 | nop 33 | ini 34 | nop 35 | nop 36 | nop 37 | ini 38 | nop 39 | nop 40 | nop 41 | ini 42 | nop 43 | nop 44 | nop 45 | ini 46 | nop 47 | nop 48 | nop 49 | ini 50 | nop 51 | nop 52 | nop 53 | ini 54 | nop 55 | nop 56 | ld B,D 57 | ini 58 | jr nz,IRBVRM0 59 | ret 60 | -------------------------------------------------------------------------------- /LIB/IWBVRM.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// IWBVRM /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Write Bloq Video RaM 6 | ; volca B blocs de 8 bytes desde direccio RAM HL a la direccio VRAM DE 7 | ; No utilitza BIOS, desavilita les interupcions 8 | ; 29/12/04 Arnau Castellvi / Zona Neutra 9 | 10 | ; B = Blocs de 8 bytes 11 | ; HL = direccio RAM 12 | ; DE = direccion VRAM 13 | 14 | ; Cal RAM : res 15 | ; Toca : A,BC,D 16 | ; Retorna : res 17 | ; Usa fun.: res 18 | 19 | IWBVRM: 20 | ld A,E 21 | out (99h),A 22 | ld A,D 23 | or 40h 24 | out (99h),A 25 | ld C,98h 26 | .loop: 27 | ld D,B 28 | outi 29 | nop 30 | nop 31 | nop 32 | outi 33 | nop 34 | nop 35 | nop 36 | outi 37 | nop 38 | nop 39 | nop 40 | outi 41 | nop 42 | nop 43 | nop 44 | outi 45 | nop 46 | nop 47 | nop 48 | outi 49 | nop 50 | nop 51 | nop 52 | outi 53 | nop 54 | nop 55 | ld B,D 56 | outi 57 | jr nz,.loop 58 | 59 | ret 60 | -------------------------------------------------------------------------------- /LIB/IWBVRMRLE.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/IWBVRMRLE.GEN -------------------------------------------------------------------------------- /LIB/IWBVRMRLE2.GEN: -------------------------------------------------------------------------------- 1 | ; /////////////////////////////////// 2 | ; ///////// IWBVRMRLE 2 ///////////// 3 | ; /////////////////////////////////// 4 | 5 | ; Write Bloq Video RaM en compresio RLE 2 amb codi de control 6 | ; al primer byte del block 7 | ; volca bytes desde direccio RAM HL a la direccio VRAM DE 8 | ; No utilitza BIOS, CAL deshabilitar les interupcions 9 | ; 29/12/04 Arnau Castellvi / Zona Neutra 10 | ; 2012 Rafel Arreglos RLE 11 | ; 2016 Rafel Arreglos RLE2 12 | 13 | ; HL = direccio RAM [codi de control al primer byte del block] 14 | ; DE = direccion VRAM 15 | 16 | ; Cal RAM : res 17 | ; Toca : A,BC,DE,HL 18 | ; Retorna : res 19 | ; Usa fun.: res 20 | 21 | ; E = byte de control 22 | ; D = byte a pujar a VRAM 23 | IWBVRMRLE2: 24 | ld A,E 25 | out (99h),A 26 | ld A,D 27 | or 40h 28 | out (99h),A 29 | ld C,98h 30 | 31 | ld A,(HL) ; Leo byte de control 32 | inc HL 33 | ld E,A ; Guardo en E el byte de control 34 | .LOOP: 35 | call READRLE1DATA ; Si devuelve 0 bytes a copiar [B] ya es fin 36 | ld A,B 37 | or A 38 | ret z 39 | 40 | ; Loop de copia 41 | .COPY_VRAM: 42 | out (C),D ; copio dato en D a VRAM 43 | nop 44 | ; *** añadido de hacer cambio de paleta a mano como interrupcion 45 | ;m_MANUAL_IE IWBVRMRLE2 46 | dec B 47 | jp nz,.COPY_VRAM 48 | ;djnz .COPY_VRAM 49 | jp .LOOP 50 | .FI: 51 | ret 52 | 53 | 54 | ; /////////////////////////////////// 55 | ; ///////// READRLE1DATA //////////// 56 | ; /////////////////////////////////// 57 | ; HL = direccio RAM del byte a llegir. 58 | ; E = byte de control [bytecode] 59 | 60 | ; Cal RAM : res 61 | ; Toca : A,BC,DE,HL 62 | ; Incrementa HL y lo deja listo para leer el siguiente datoRLE 63 | ; Retorna : 64 | ; D = byte a copiar 65 | ; B = veces que se ha de copiar 66 | ; Usa fun.: res 67 | READRLE1DATA: 68 | ld A,(HL) ; Leo byte 69 | inc HL 70 | cp E ; Si byte es bytecode 71 | jr nz,.NOES_BYTECODE 72 | ld A,(HL) ; Leo byte 73 | inc HL 74 | .CONTROL_0: 75 | or A 76 | jr nz,.CONTROL_1 77 | ; Case 0: Fi de datas 78 | ld B,0 ; Un cero en B indica que ya no hay mas datos que copiar 79 | jr .END 80 | .CONTROL_1: 81 | cp 1 82 | jr nz,.CONTROL_2 83 | ; Case 1: copiar 1 vez el byte de control 84 | ld B,1 ; a copiar 1 vez 85 | ld D,E ; Pongo byte de control 86 | jr .END 87 | .CONTROL_2: 88 | cp 2 89 | jr nz,.CONTROL_N 90 | ; Case 2: copiar 2 veces el byte de control 91 | ld B,2 ; a copiar 2 veces 92 | ld D,E ; Pongo byte de control 93 | jr .END 94 | .CONTROL_N: 95 | ; Case N: copiar N veces el byte de control 96 | ld B,A ; a copiar N veces 97 | ld A,(HL) ; Leo byte 98 | inc HL 99 | ld D,A ; Pongo byte leido a copiar 100 | jr .END 101 | .NOES_BYTECODE: 102 | ld B,1 ; a copiar 1 vez 103 | ld D,A ; el byte que esta sin comprimir 104 | .END: 105 | ret 106 | 107 | ; /////////////////////////////////// 108 | ; ///////// WBRMRMRLE 2 ///////////// 109 | ; /////////////////////////////////// 110 | 111 | ; Write Bloq RaM to RaM en compresio RLE 2 amb codi de control 112 | ; al primer byte del block 113 | ; volca bytes desde direccio RAM HL a la direccio RAM DE 114 | ; No utilitza BIOS 115 | 116 | ; HL = direccio RAM origen [codi de control al primer byte del block] 117 | ; DE = direccio RAM destino 118 | 119 | ; Cal RAM : res 120 | ; Toca : A,BC,DE,HL 121 | ; Retorna : res 122 | ; Usa fun.: res 123 | 124 | ; E = byte de control 125 | ; D = byte a pujar a VRAM 126 | WBRMRMRLE2: 127 | push DE 128 | pop IY ; Direccion destino en IY 129 | 130 | ld A,(HL) ; Leo byte de control 131 | inc HL 132 | ld E,A ; Guardo en E el byte de control 133 | .LOOP: 134 | call READRLE1DATA ; Si devuelve 0 bytes a copiar [B] ya es fin 135 | ld A,B 136 | or A 137 | jr z,.FI 138 | 139 | ; Loop de copia 140 | .COPY_RAM: 141 | ld (IY),D ; copio dato en D RAM Registro IY 142 | inc IY 143 | djnz .COPY_RAM 144 | jr .LOOP 145 | .FI: 146 | ret 147 | -------------------------------------------------------------------------------- /LIB/KEY2JOY.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// KEY2JOY /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Agafa els valors del teclat i els pasa a JOYSTICK 6 | 7 | ; A = Valor retornat per MIRATECLA 8 | ; HL = Posicio variable JOY1 9 | 10 | ; Cal RAM : res 11 | ; Toca : res 12 | ; Retorna : Posicio (HL) bits 5-0 [B/A/R/L/D/U] per 1 13 | ; Usa fun.: res 14 | 15 | KEY2JOY: 16 | cp 1 ; Cursor ESQUERRA 17 | jr z,.LEFT 18 | cp 2 ; Cursor AMUNT 19 | jr z,.UP 20 | cp 3 ; Cursor ABALL 21 | jr z,.DOWN 22 | cp 4 ; Cursor DRETA 23 | jr z,.RIGHT 24 | cp 6 ; GRAPH -> Button B 25 | jr z,.BUTB 26 | cp 32 ; ESPAI -> Button A 27 | jr z,.BUTA 28 | cp 77 ; M -> Button B 29 | jr z,.BUTB 30 | ret 31 | ; Retorna : Posicio (HL) bits 5-0 [B/A/R/L/D/U] per 1 32 | .UP: 33 | ld A,00000001b 34 | ld (HL),A 35 | ret 36 | .DOWN: 37 | ld A,00000010b 38 | ld (HL),A 39 | ret 40 | .LEFT: 41 | ld A,00000100b 42 | ld (HL),A 43 | ret 44 | .RIGHT: 45 | ld A,00001000b 46 | ld (HL),A 47 | ret 48 | .BUTA: 49 | ld A,00010000b 50 | ld (HL),A 51 | ret 52 | .BUTB: 53 | ld A,00100000b 54 | ld (HL),A 55 | ret 56 | -------------------------------------------------------------------------------- /LIB/LOADGFX.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// LOADGFX ////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Posicionamiento de GFX en pantalla 6 | ; Carrega a VRAM tiles de un GFX a BANK 0,1 i 2 Iguals 7 | ; MIDA MAX X*Y < 256 8 | ; utilitza screen2 9 | ; by ARNAU [amb modificacions] 10 | 11 | ; C = 1era TILE on posar les dades. 12 | ; IX = GFX a posar [X,Y,Data] 13 | 14 | ; Cal RAM : res 15 | ; Toca : BC,DE,HL 16 | ; DESACTIVA INTERRUPCIO !!! 17 | ; Retorna : res 18 | ; Usa fun.: IWBVRM [A,BC,D] 19 | 20 | LOADGFX: 21 | push AF ; Guardo l'estat actual de EI/DI 22 | di 23 | ; Posar Colors i patterns a VRAM 24 | ; Primer Multiplico X*Y per saber quants tiles pujar 25 | ld D,(IX) 26 | ld B,(IX+1) 27 | xor A 28 | .LOOPMUL: 29 | add A,D 30 | djnz .LOOPMUL 31 | ; Queda en A X*Y 32 | ld HL,0 33 | ld E,C 34 | ld D,0 35 | ld B,8 36 | .LOOPMUL2: 37 | add HL,DE 38 | djnz .LOOPMUL2 39 | ld DE,VRM_COL ; Punter a BANK0 40 | add HL,DE 41 | push HL 42 | pop DE ; HL->DE Punter a BANK0 + Offset C 43 | 44 | push IX 45 | pop HL ; IX ->HL 46 | inc HL 47 | inc HL ; Offset del GFX de Colors 48 | 49 | ld B,A ; Poso a B Tiles a Pujar X*Y 50 | 51 | push BC ; Guardo el Calculo de X*Y [de B] 52 | push HL 53 | push DE 54 | CALL IWBVRM ; Pasa blocks de 8 bytes a VRAM Bank0 55 | 56 | pop HL ; DE->HL Recupero BANK0 + Offset C a HL per 57 | ; fer suma de 2048 58 | ld DE,2048 59 | add HL,DE 60 | push HL 61 | pop DE ; HL->DE Punter a BANK1 + Offset C 62 | 63 | pop HL ; Recupero Offset del GFX de Colors 64 | pop BC ; Pop de blocks [de B] de 8 bytes a VRAM 65 | 66 | push BC ; Guardo el Calculo de X*Y [de B] 67 | push HL 68 | push DE 69 | CALL IWBVRM ; Pasa blocks de 8 bytes a VRAM Bank1 70 | 71 | pop HL ; DE->HL Recupero BANK1 + Offset C a HL per 72 | ; fer suma de 2048 73 | ld DE,2048 74 | add HL,DE 75 | push HL 76 | pop DE ; HL->DE Punter a BANK2 + Offset C 77 | 78 | pop HL ; Recupero Offset del GFX de Colors 79 | pop BC ; Pop de blocks [de B] de 8 bytes a VRAM 80 | 81 | push BC ; Guardo el Calculo de X*Y [de B] 82 | CALL IWBVRM ; Pasa blocks de 8 bytes a VRAM Bank2 83 | 84 | ;;; PATTERNS---- 85 | pop BC ; Pop de C per 1era tile 86 | push BC 87 | 88 | push HL ; HL Offset del GFX de Patterns 89 | ; ja queda per IWBVRM a HL, el Guardo 90 | ld HL,0 91 | ld E,C 92 | ld D,0 93 | ld B,8 94 | .LOOPMUL3: 95 | add HL,DE 96 | djnz .LOOPMUL3 97 | ld DE,VRM_PAT ; Punter a BANK0 Pattern 98 | add HL,DE 99 | push HL 100 | pop DE ; HL->DE Punter a BANK0 + Offset C 101 | 102 | pop HL ; Recupero Offset del GFX de Patterns 103 | pop BC ; Pop de blocks [de B] de 8 bytes a VRAM 104 | 105 | push BC ; Guardo el Calculo de X*Y [de B] 106 | push HL 107 | push DE 108 | CALL IWBVRM ; Pasa blocks de 8 bytes a VRAM Bank0 109 | 110 | pop HL ; DE->HL Recupero BANK0 + Offset C a HL per 111 | ; fer suma de 2048 112 | ld DE,2048 113 | add HL,DE 114 | push HL 115 | pop DE ; HL->DE Punter a BANK1 + Offset C 116 | 117 | pop HL ; Recupero Offset del GFX de Patterns 118 | pop BC ; Pop de blocks [de B] de 8 bytes a VRAM 119 | 120 | push BC ; Guardo el Calculo de X*Y [de B] 121 | push HL 122 | push DE 123 | CALL IWBVRM ; Pasa blocks de 8 bytes a VRAM Bank1 124 | 125 | pop HL ; DE->HL Recupero BANK1 + Offset C a HL per 126 | ; fer suma de 2048 127 | ld DE,2048 128 | add HL,DE 129 | push HL 130 | pop DE ; HL->DE Punter a BANK2 + Offset C 131 | 132 | pop HL ; Recupero Offset del GFX de Patterns 133 | pop BC ; Pop de blocks [de B] de 8 bytes a VRAM 134 | 135 | CALL IWBVRM ; Pasa blocks de 8 bytes a VRAM Bank2 136 | 137 | pop AF ; Recupero l'estat de EI/DI 138 | ret 139 | -------------------------------------------------------------------------------- /LIB/LOADSC5.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////// 2 | ; ///////// LOADSC5 ////////// 3 | ; //////////////////////////// 4 | 5 | ; Write Bloq Video RaM 6 | ; Compresio RLE2 (WB) amb codi de control al primer byte 7 | ; Volca direccio RAM HL a la direccio VRAM DE 8 | ; No utilitza BIOS, CAL deshabilitar les interupcions 9 | ; versio MSX2 per Screen 5 10 | ; Basat en IWBVRM5RLE2 11 | ; * No fas servir MegaROM. S'espera tot junt 12 | ; 02/08/2023 Rafel 13 | 14 | ; B = Pagina on va Grafic 15 | ; HL = direccio RAM (codi de control al primer byte del block) 16 | ; DE = direccion VRAM 17 | 18 | ; Cal RAM : res 19 | ; Toca : A,BC,DE,HL 20 | ; Retorna : res 21 | ; Usa fun.: READRLE1DATA de IWBVRRLE2.GEN 22 | 23 | LOADSC5: 24 | ld A,D 25 | and 01000000b ; Bits A15-A13 de direccio VRAM (A15 es page) 26 | srl A 27 | srl A 28 | srl A 29 | srl A 30 | srl A 31 | srl A 32 | sla B ; A16-A15 Ve per B 33 | or B 34 | m_WRITE_DATA_REGISTER 0Eh ; Register 0Eh: VRAM access (VRAM address select, higher address lines) 35 | ld A,E ; Bits A7-A0 de direccio VRAM 36 | out (99h),A 37 | ld A,D ; Bits A13-A8 de direccio VRAM 38 | and 00111111b 39 | or 40h 40 | out (99h),A 41 | ld C,98h 42 | 43 | ld E,(HL) ; Leo byte de control + Guardo en E el byte de control 44 | inc HL 45 | .LOOP: 46 | call READRLE1DATA ; Si devuelve 0 bytes a copiar (B) ya es fin 47 | ld A,B 48 | or A 49 | ret z 50 | 51 | ; Loop de copia 52 | .COPY_VRAM: 53 | out (C),D ; copio dato en D a VRAM 54 | ; Sin esperas del VDP. Es MSX2 55 | dec B 56 | jp nz,.COPY_VRAM 57 | jp .LOOP 58 | .FI: 59 | ret 60 | -------------------------------------------------------------------------------- /LIB/MACROSVDP.ASM: -------------------------------------------------------------------------------- 1 | ; MACROS PARA VDP MSX2 2 | 3 | ; A = Register Status to Set 4 | m_SET_STATUS_REGISTER: MACRO 5 | out (99h),A 6 | ld (VDP_REG + 0Fh),A 7 | ld A,80h + 0Fh ; Register 0Fh: Status Register Index 8 | out (99h),A 9 | ENDM 10 | 11 | m_READ_STATUS_REGISTER: MACRO 12 | in A,(99h) 13 | ENDM 14 | 15 | ; A = Data to Write to Register 16 | m_WRITE_DATA_REGISTER: MACRO #REG 17 | out (99h),A 18 | ld (VDP_REG + #REG),A 19 | ld A,80h + #REG ; Register to Write 20 | out (99h),A 21 | ENDM 22 | 23 | ; Flag NZ if V-Blank happens 24 | m_CHECK_VBLANK: MACRO 25 | xor A ; Status Register 0 26 | out (99h),A 27 | ld (VDP_REG + 0Fh),A 28 | ld A,80h + 0Fh ; Register 0Fh: Status Register Index 29 | out (99h),A 30 | in A,(99h) 31 | and 10000000b ; 7 F V-Blank IRQ Flag (1=interrupt) 32 | ENDM 33 | 34 | ; Flag NZ if V-Blank happens 35 | m_CHECK_HBLANK: MACRO 36 | ld A,1 ; Status Register 1 37 | out (99h),A 38 | ld (VDP_REG + 0Fh),A 39 | ld A,80h + 0Fh ; Register 0Fh: Status Register Index 40 | out (99h),A 41 | in A,(99h) 42 | and 00000001b ;0 FH Horizontal Retrace IRQ Flag 43 | ENDM 44 | -------------------------------------------------------------------------------- /LIB/MEGAROM.GEN: -------------------------------------------------------------------------------- 1 | ; Rutines per posicionar págines MEGAROM 2 | 3 | 4 | 5 | ; ///////////////////////////////////// 6 | ; ///////// MEGAROM_SETGFXPAGES ////// 7 | ; ///////////////////////////////////// 8 | 9 | ; HL = GFX a cargar, estructura de 7 bytes 10 | 11 | ; Cal RAM : GFXDATA_OLDPAGES, GFXDATASC5 12 | ; Toca : res 13 | ; Retorna : res 14 | ; Usa fun.: res 15 | 16 | MEGAROM_SETGFXPAGES: 17 | xor A 18 | ld (GFXDATA_OLDPAGES),A 19 | ld (GFXDATA_OLDPAGES+1),A 20 | ld (GFXDATA_OLDPAGES+2),A 21 | ; Preparem las Pages 22 | ld A,(06000h) 23 | ld (GFXDATA_OLDPAGES),A 24 | ld A,(GFXDATASC5) 25 | or A 26 | jr z,.NEXT8000 27 | ld A,(GFXDATASC5) 28 | SELECT A AT 06000h 29 | 30 | .NEXT8000: 31 | ld A,(08000h) 32 | ld (GFXDATA_OLDPAGES+1),A 33 | ld A,(GFXDATASC5+1) 34 | or A 35 | jr z,.NEXTA000 36 | ld A,(GFXDATASC5+1) 37 | SELECT A AT 08000h 38 | 39 | .NEXTA000: 40 | ld A,(0A000h) 41 | ld (GFXDATA_OLDPAGES+2),A 42 | ld A,(GFXDATASC5+2) 43 | or A 44 | ret z 45 | ld A,(GFXDATASC5+2) 46 | SELECT A AT 0A000h 47 | ret 48 | 49 | 50 | ; ////////////////////////////////////// 51 | ; ///////// MEGAROM_RESTOREPAGES ////// 52 | ; ////////////////////////////////////// 53 | 54 | ; Cal RAM : GFXDATA_OLDPAGES, GFXDATASC5 55 | ; Toca : res 56 | ; Retorna : res 57 | ; Usa fun.: res 58 | 59 | MEGAROM_RESTOREPAGES: 60 | ; Recuperem las Pages 61 | ld A,(GFXDATA_OLDPAGES) 62 | or A 63 | jr z, .NEXT8000 64 | SELECT A AT 06000h 65 | .NEXT8000: 66 | ld A,(GFXDATA_OLDPAGES+1) 67 | or A 68 | jr z, .NEXTA000 69 | SELECT A AT 08000h 70 | .NEXTA000: 71 | ld A,(GFXDATA_OLDPAGES+2) 72 | or A 73 | jr z,.END 74 | SELECT A AT 0A000h 75 | .END: 76 | xor A 77 | ld (GFXDATA_OLDPAGES),A 78 | ld (GFXDATA_OLDPAGES+1),A 79 | ld (GFXDATA_OLDPAGES+2),A 80 | ld (GFXDATASC5),A 81 | ld (GFXDATASC5+1),A 82 | ld (GFXDATASC5+2),A 83 | ret 84 | -------------------------------------------------------------------------------- /LIB/MINIPSG.GEN: -------------------------------------------------------------------------------- 1 | ; Rutines per so RAPID 2 | 3 | TIMER_MINIPSG equ 3 4 | 5 | ; ////////////////////////////////// 6 | ; ///////// PLAYAMBIENT //////////// 7 | ; ////////////////////////////////// 8 | ; Inicia els timers a zero 9 | ; HL = Etiqueta de so_ambient a fer play 10 | ; Registres: 0,1,2,3,6,7,8,9,B,C,D 11 | ; Cal RAM : 12 | ; Toca : HL 13 | ; Retorna : res 14 | ; Usa fun.: 15 | 16 | PLAYAMBIENT: 17 | push AF 18 | push BC 19 | ld B,4 ; 0-3 20 | ld C,0 21 | .PLAY_03: 22 | ld A,C 23 | out (0A0h),A 24 | ld A,(HL) 25 | out (0A1h),A 26 | inc C 27 | inc HL 28 | djnz .PLAY_03 29 | inc C 30 | inc C 31 | ; Reg 6 32 | ld A,C 33 | out (0A0h),A 34 | ld A,(HL) 35 | out (0A1h),A 36 | inc C 37 | inc HL 38 | ; Reg 7 [Con mascara solo canal 1-2] 39 | ld A,C 40 | out (0A0h),A 41 | in A,(0A2h) 42 | and 11100100b ; Conservo el canal 3 43 | ld B,A 44 | ld A,(HL) 45 | and 00011011b 46 | or B 47 | ld B,A 48 | ld A,C 49 | out (0A0h),A 50 | ld A,B 51 | out (0A1h),A 52 | inc HL 53 | ; 54 | inc C 55 | ld B,2 ;8-9 56 | .PLAY_89: ld A,C 57 | out (0A0h),A 58 | ld A,(HL) 59 | out (0A1h),A 60 | inc C 61 | inc HL 62 | djnz .PLAY_89 63 | inc C 64 | ld B,3 ;B-D 65 | .PLAY_BD: ld A,C 66 | out (0A0h),A 67 | ld A,(HL) 68 | out (0A1h),A 69 | inc C 70 | inc HL 71 | djnz .PLAY_BD 72 | 73 | pop BC 74 | pop AF 75 | ret 76 | 77 | PLAYRNDINI: 78 | push AF 79 | push BC 80 | ld A,R ; Pillo un valor random 81 | sla A 82 | sla A 83 | sla A 84 | ld (PLAYRNDVALUE),A 85 | ld A,30 86 | ld (PLAYRNDTIMES),A 87 | ld BC,TIMER_MINIPSG*256+30 ; B Timer C Valor 88 | call TIMERSET 89 | xor A 90 | ld A,(PLAYAMBION) 91 | pop BC 92 | pop AF 93 | ret 94 | 95 | PLAYRNDTIMER: ; SOLO CANAL 3 96 | push AF 97 | push BC 98 | ; Que PLAYRNDTIME sea mayor que cero 99 | ld A,(PLAYRNDTIMES) 100 | or A 101 | jr z,.MUTECANAL3 ; Me piro si ya es 0 y bajo volumen 102 | dec A 103 | ld (PLAYRNDTIMES),A ; Decremento 1 vez 104 | ld A,4 105 | out (0A0h),A 106 | ld A,(PLAYRNDVALUE) 107 | ld B,A 108 | ld A,R ; Regenero el random 109 | add A,B 110 | sla A 111 | sla A 112 | sla A 113 | ld (PLAYRNDVALUE),A ; Lo guardo 114 | out (0A1h),A 115 | 116 | ld A,5 117 | out (0A0h),A 118 | xor A 119 | out (0A1h),A 120 | 121 | ; Reg 7 [Con mascara solo canal 3 y solo BEEP] 122 | ld A,7 ; Lo leo 123 | out (0A0h),A 124 | in A,(0A2h) 125 | and 11111011b ; Abro canal 3 126 | ld B,A 127 | ld A,7 128 | out (0A0h),A 129 | ld A,B 130 | out (0A1h),A ; Lo subo a canal 7 131 | 132 | ; Registro 10 - Volumen a 8 133 | ld A,10 134 | out (0A0h),A 135 | ld A,8 136 | out (0A1h),A 137 | jr .FUERA 138 | .MUTECANAL3: 139 | ld A,TIMER_MINIPSG 140 | call TIMERCHECK 141 | jr z,.FUERA 142 | ; Registro 10 - Volumen a 0 143 | ld A,10 144 | out (0A0h),A 145 | xor A 146 | out (0A1h),A 147 | .FUERA: 148 | pop BC 149 | pop AF 150 | ret 151 | 152 | ; ///////////////////////////// 153 | ; ///////// PLAYFX //////////// 154 | ; ///////////////////////////// 155 | ; Inicia els timers a zero 156 | ; HL = Etiqueta de so_ambient a fer play 157 | ; C = Temps del FX en frames 158 | ; Registres: 0,1,2,3,6,7,8,9,B,C,D 159 | ; Cal RAM : 160 | ; Toca : HL 161 | ; Retorna : res 162 | ; Usa fun.: PLAYAMBIENT 163 | PLAYFX: 164 | push BC 165 | xor A 166 | ld (PLAYAMBION),A 167 | ld B,TIMER_MINIPSG ; B Timer 168 | ; C Valor 169 | call TIMERSET 170 | ;call PSGMUTE 171 | call PLAYAMBIENT 172 | pop BC 173 | ret 174 | -------------------------------------------------------------------------------- /LIB/MIRATECLA.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; //////// MIRATECLA ///////////// 3 | ; //////////////////////////////// 4 | 5 | ; control de teclat. Pasa de teclat a codi ascii 6 | ; MODIFICAT PER RAFEL PERQUE RETORNI SEMPRE EL VALOR DEL 7 | ; DEL BUFFER DE TECLAT SENSE EL CONTADOR DE INTERRUPCIONS 8 | ; ----------------------- 9 | ; NOTA !! 10 | ; S'han posat ; a les tecles q no es fan servir per aixi 11 | ; tenir mas espai de codi. Cal descomentar les tecles que es 12 | ; fan servir. 13 | ; Cal fer etiquetes MIRATXX tantes com tecles actives amb el 14 | ; XX corresponent fent el retorn. 15 | ; ----------------------- 16 | 17 | ; Cal RAM : KEYBOARD 18 | ; Toca : A,IX 19 | ; Retorna : A [Codi ASCII] 20 | ; Usa fun.: res 21 | 22 | MIRATECLA: 23 | ld IX,KEYBOARD 24 | ;-- 1 -- 25 | bit 0,(IX+1) 26 | jp z,MIRAT32 ;ESPAI [32] 27 | ; bit 1,(IX+1) 28 | ; jp z,MIRAT00 ;HOME 29 | ; bit 2,(IX+1) 30 | ; jp z,MIRAT00 ;INS 31 | ; bit 3,(IX+1) 32 | ; jp z,MIRAT00 ;DEL 33 | bit 4,(IX+1) 34 | jp z,MIRAT01 ;CURSOR ESQUERRA [1] 35 | bit 5,(IX+1) 36 | jp z,MIRAT02 ;CURSOR AMUNT [2] 37 | bit 6,(IX+1) 38 | jp z,MIRAT03 ;CURSOR ABALL [3] 39 | bit 7,(IX+1) 40 | jp z,MIRAT04 ;CURSOR DRETA [4] 41 | ;-- 2 -- 42 | ; bit 0,(IX+2) 43 | ; jp z,MIRATF4 ;F4 44 | ; bit 1,(IX+2) 45 | ; jp z,MIRATF5 ;F5 46 | bit 2,(IX+2) 47 | jp z,MIRAT27 ;ESC [27] 48 | ; bit 3,(IX+2) 49 | ; jp z,MIRAT11 ;TAB [11] 50 | ; bit 4,(IX+2) 51 | ; jp z,MIRAT00 ;STOP 52 | ; bit 5,(IX+2) 53 | ; jp z,MIRAT08 ;BACKSPACE [BS] [8] 54 | ; bit 6,(IX+2) 55 | ; jp z,MIRATSELECT ;SELECT [F6] 56 | ; bit 7,(IX+2) 57 | ; jp z,MIRAT13 ;ENTER [13] 58 | ;-- 3 -- 59 | ; bit 0,(IX+3) 60 | ; jp z,MIRAT00 ;SHIFT 61 | ; bit 1,(IX+3) 62 | ; jp z,MIRAT00 ;CONTROL 63 | bit 2,(IX+3) 64 | jp z,MIRAT06 ;GRAPH [Alt] [6] 65 | ; bit 3,(IX+3) 66 | ; jp z,MIRAT00 ;CAPS LOCK [MAYUSCULAS] 67 | ; bit 4,(IX+3) 68 | ; jp z,MIRAT00 ;CODE 69 | bit 5,(IX+3) 70 | jp z,MIRATF1 ;F1 71 | ; bit 6,(IX+3) 72 | ; jp z,MIRAT00 ;F2 73 | ; bit 7,(IX+3) 74 | ; jp z,MIRAT00 ;F3 75 | ;-- 4 -- 76 | ; bit 0,(IX+4) 77 | ; jp z,MIRAT83 ; S [83] 78 | ; bit 1,(IX+4) 79 | ; jp z,MIRAT84 ; T [84] 80 | ; bit 2,(IX+4) 81 | ; jp z,MIRAT85 ; U [85] 82 | ; bit 3,(IX+4) 83 | ; jp z,MIRAT86 ; V [86] 84 | ; bit 4,(IX+4) 85 | ; jp z,MIRAT87 ; W [87] 86 | ; bit 5,(IX+4) 87 | ; jp z,MIRAT88 ; X [88] 88 | ; bit 6,(IX+4) 89 | ; jp z,MIRAT89 ; Y [89] 90 | ; bit 7,(IX+4) 91 | ; jp z,MIRAT90 ; Z [90] 92 | ;-- 5 -- 93 | ; bit 0,(IX+5) 94 | ; jp z,MIRAT75 ; K [75] 95 | ; bit 1,(IX+5) 96 | ; jp z,MIRAT76 ; L [76] 97 | bit 2,(IX+5) 98 | jp z,MIRAT77 ; M [77] 99 | ; bit 3,(IX+5) 100 | ; jp z,MIRAT78 ; N [78] 101 | ; bit 4,(IX+5) 102 | ; jp z,MIRAT79 ; O [79] 103 | ; bit 5,(IX+5) 104 | ; jp z,MIRAT80 ; P [80] 105 | ; bit 6,(IX+5) 106 | ; jp z,MIRAT81 ; Q [81] 107 | ; bit 7,(IX+5) 108 | ; jp z,MIRAT82 ; R [82] 109 | ;-- 6 -- 110 | ; bit 0,(IX+6) 111 | ; jp z,MIRAT67 ; C [67] 112 | ; bit 1,(IX+6) 113 | ; jp z,MIRAT68 ; D [68] 114 | ; bit 2,(IX+6) 115 | ; jp z,MIRAT69_ ; E [69] 116 | ; bit 3,(IX+6) 117 | ; jp z,MIRAT70 ; F [70] 118 | ; bit 4,(IX+6) 119 | ; jp z,MIRAT71 ; G [71] 120 | ; bit 5,(IX+6) 121 | ; jp z,MIRAT72 ; H [72] 122 | ; bit 6,(IX+6) 123 | ; jp z,MIRAT73 ; I [73] 124 | ; bit 7,(IX+6) 125 | ; jp z,MIRAT74 ; J [74] 126 | ;-- 7 -- 127 | ; bit 0,(IX+7) 128 | ; jp z,MIRAT96 ; ` Acento [96] [´¨abrir llave] 129 | ; bit 1,(IX+7) 130 | ; jp z,MIRAT39 ; ' Apostrofe [39] [ºª\] 131 | ; bit 2,(IX+7) 132 | ; jp z,MIRAT44 ; , Coma [44] 133 | ; bit 3,(IX+7) 134 | ; jp z,MIRAT46 ; . Punto [46] 135 | ; bit 4,(IX+7) 136 | ; jp z,MIRAT47 ; / Dividir [47] [-_] 137 | ; bit 5,(IX+7) 138 | ; jp z,MIRAT01 ; ??? [01] [Control] 139 | ; bit 6,(IX+7) 140 | ; jp z,MIRAT65 ; A [65] 141 | ; bit 7,(IX+7) 142 | ; jp z,MIRAT66 ; B [66] 143 | ;-- 8 -- 144 | ; bit 0,(IX+8) 145 | ; jp z,MIRAT56 ; 8 [56] 146 | ; bit 1,(IX+8) 147 | ; jp z,MIRAT57 ; 9 [57] 148 | ; bit 2,(IX+8) 149 | ; jp z,MIRAT45 ; - Resta [45] ['?] 150 | ; bit 3,(IX+8) 151 | ; jp z,MIRAT61 ; = Igual [61] [¡¿] 152 | ; bit 4,(IX+8) 153 | ; jp z,MIRAT92 ; \ Contrabarra [92] [ç cerrar llave] 154 | ; bit 5,(IX+8) 155 | ; jp z,MIRAT91 ; [ 156 | ; bit 6,(IX+8) 157 | ; jp z,MIRAT93 ; ] 158 | ; bit 7,(IX+8) 159 | ; jp z,MIRAT59 ; ; [ñ] 160 | ;-- 9 -- 161 | ; bit 0,(IX+9) 162 | ; jp z,MIRAT48 ; 0 [48] 163 | ; bit 1,(IX+9) 164 | ; jp z,MIRAT49 ; 1 [49] 165 | ; bit 2,(IX+9) 166 | ; jp z,MIRAT50 ; 2 [50] 167 | ; bit 3,(IX+9) 168 | ; jp z,MIRAT51 ; 3 [51] 169 | ; bit 4,(IX+9) 170 | ; jp z,MIRAT52 ; 4 [52] 171 | ; bit 5,(IX+9) 172 | ; jp z,MIRAT53 ; 5 [53] 173 | ; bit 6,(IX+9) 174 | ; jp z,MIRAT54 ; 6 [54] 175 | ; bit 7,(IX+9) 176 | ; jp z,MIRAT55 ; 7 [55] 177 | 178 | MIRAT00: 179 | xor A 180 | ret 181 | ;/////////////////////////////////// 182 | 183 | MIRAT32: 184 | ld A,32 185 | ret 186 | MIRAT27: 187 | ld A,27 188 | ret 189 | MIRAT01: 190 | ld A,1 191 | ret 192 | MIRAT02: 193 | ld A,2 194 | ret 195 | MIRAT03: 196 | ld A,3 197 | ret 198 | MIRAT04: 199 | ld A,4 200 | ret 201 | MIRAT06: 202 | ld A,6 203 | ret 204 | MIRAT77: 205 | ld A,77 206 | ret 207 | MIRATF1: 208 | ld A,0F1h 209 | ret 210 | -------------------------------------------------------------------------------- /LIB/MOUSE.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/MOUSE.GEN -------------------------------------------------------------------------------- /LIB/MSX2_PUTPAL.GEN: -------------------------------------------------------------------------------- 1 | ; /////////////////////////////// 2 | ; ///////// PUTPAL // SCR4-7 // 3 | ; /////////////////////////////// 4 | 5 | ; Pone una paleta nueva en los registros 6 | ; Codigos de color de 0 a 15 [16 en total] 7 | 8 | ; HL = Offset de la paleta en RAM/ROM 9 | 10 | ; Cal RAM : res 11 | ; Toca : C 12 | ; Retorna : res 13 | ; Usa fun.: res 14 | 15 | PUTPAL: 16 | xor A 17 | m_WRITE_DATA_REGISTER 10h ; Register 10h: Palette Index 18 | ld C,9Ah ; 32 vegades a port 9A 19 | 20 | ; Sin esperas pq VDP del MSX2 no las requiere. 21 | REPT 32 22 | outi 23 | nop 24 | nop 25 | nop 26 | ENDR 27 | 28 | ret 29 | 30 | ; //////////////////////////////////////// 31 | ; ///////// PUTPAL_ONECOLOR // SCR4-7 // 32 | ; //////////////////////////////////////// 33 | 34 | ; Pone un color solo a la paleta activa 35 | ; Codigos de color de 0 a 15 [16 en total] 36 | 37 | ; A = Codigo de color 0-15 38 | ; HL = Color RBG H=RB L=G 39 | 40 | ; Cal RAM : res 41 | ; Toca : C 42 | ; Retorna : res 43 | ; Usa fun.: res 44 | 45 | PUTPAL_ONECOLOR: 46 | push AF 47 | m_WRITE_DATA_REGISTER 10h ; Register 10h: Palette Index 48 | 49 | ld C,9Ah ; a port 9A 50 | out (C),H 51 | out (C),L 52 | xor A ; Reset al registre de color inicial amb 0 53 | m_WRITE_DATA_REGISTER 10h ; Register 10h: Palette Index 54 | pop AF 55 | ret 56 | -------------------------------------------------------------------------------- /LIB/MSX2_SCREEN.GEN: -------------------------------------------------------------------------------- 1 | ; Rutines per VDP 9938 MSX2 2 | 3 | ; Fa que el color 0 no sigui transparent 4 | SCREEN_SOLIDCOLOR0: 5 | ld A,(VDP_REG+8) 6 | ; 5 TP Transparent from palette (0=Normal, 1=Color 0 is solid) 7 | or 00100000b ; Transparent from palette 8 | m_WRITE_DATA_REGISTER 08h ; Register 8: Mode register 2 9 | ret 10 | 11 | ; Activa H-Blank 12 | ; Requereix interrupcions deshabilitades 13 | SCREEN_SET_HBLANK: 14 | ld A,(VDP_REG+0) 15 | ; 4 IE1 H-Blank Interrupt Enable (MSX2 only) (see also VDP Reg 13h) 16 | or 00010000b ; H-Blank Interrupt Enable 17 | m_WRITE_DATA_REGISTER 00h ; Register 0: Mode register 0 18 | ret 19 | 20 | ; Desactiva H-Blank 21 | ; Requereix interrupcions deshabilitades 22 | SCREEN_UNSET_HBLANK: 23 | ld A,(VDP_REG+0) 24 | ; 4 IE1 H-Blank Interrupt Enable (MSX2 only) (see also VDP Reg 13h) 25 | and 11101111b ; H-Blank Interrupt Enable 26 | m_WRITE_DATA_REGISTER 00h ; Register 0: Mode register 0 27 | ret 28 | 29 | 30 | -------------------------------------------------------------------------------- /LIB/MSX2_SPRTLDPOS.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// SPRTLDPOS //////////// 3 | ; //////////////////////////////// 4 | 5 | ; SPRiTes pattern LoaD to POSition 6 | 7 | ; CAL DI ! 8 | 9 | ; B = Sprites a pujar de 16x16 10 | ; L = Num Patro inicial a fer el load a VRAM 11 | ; DE = Punter dels patrons del Sprites 12 | 13 | ; Cal ROM : res 14 | ; Toca : B,HL,DE 15 | ; Retorna : res 16 | ; Usa fun.: IWBVRM 17 | 18 | SPRTLDPOS: 19 | push DE 20 | ; L * 32 21 | ld H,0 ; *32 con acarreo (5 veces) 22 | add hl,hl ; la distancia al sprite 23 | add hl,hl ; que toca. 24 | add hl,hl 25 | add hl,hl 26 | add hl,hl 27 | ld DE,[VRM_SPP & 0FFFFh] 28 | add HL,DE 29 | push HL 30 | pop DE ; En DE direccio VRAM 31 | pop HL ; En HL direccio RAM 32 | ld A,VRM_SPP_HIGH ; Bits A16-A14 33 | m_WRITE_DATA_REGISTER 0Eh ; Register 0Eh: VRAM access (VRAM address select, higher address lines) 34 | ld A,E ; Bits A7-A0 de direccio VRAM 35 | out (99h),A 36 | ld A,D ; Bits A13-A8 de direccio VRAM 37 | and 00111111b 38 | or 40h ; Desired VRAM Direction (0=Reading, 1=Writing) 39 | out (99h),A 40 | ld C,98h 41 | sla B ; Multiplica * 8 42 | sla B 43 | sla B 44 | .COPY_VRAM: 45 | outi 46 | inc B 47 | outi 48 | inc B 49 | outi 50 | inc B 51 | outi 52 | ; Sin esperas del VDP. Es MSX2 53 | jp nz,.COPY_VRAM 54 | ret 55 | -------------------------------------------------------------------------------- /LIB/MSX2_SPRTLDPOS_FROMBANK.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ////// SPRTLDPOS_FROMBANK ////// 3 | ; //////////////////////////////// 4 | 5 | ; SPRiTes pattern LoaD FROM a ROM BANK label to POSition 6 | 7 | ; CAL DI ! 8 | 9 | ; A = Patro Inicial de Sprite del bank a pujar 10 | ; B = Quantitat de Sprites a pujar de 16x16 11 | ; L = Num Patro inicial a fer el load a VRAM 12 | ; DE = Punter dels patrons del Sprites 13 | 14 | ; Cal ROM : res 15 | ; Toca : B,HL,DE 16 | ; Retorna : res 17 | ; Usa fun.: IWBVRM 18 | 19 | SPRTLDPOS_FROMBANK: 20 | push HL 21 | ld L,A 22 | ; A * 32 23 | ld H,0 ; *32 con acarreo (5 veces) 24 | add hl,hl ; la distancia al sprite 25 | add hl,hl ; que toca. de ROM 26 | add hl,hl 27 | add hl,hl 28 | add hl,hl 29 | add HL,DE ; DE = Punter dels patrons del Sprites 30 | push HL 31 | pop DE ; En DE direccio RAM 32 | pop HL 33 | push DE 34 | ; L * 32 35 | ld H,0 ; *32 con acarreo (5 veces) 36 | add hl,hl ; la distancia al sprite 37 | add hl,hl ; que toca. de VRAM 38 | add hl,hl 39 | add hl,hl 40 | add hl,hl 41 | ld DE,[VRM_SPP & 0FFFFh] 42 | add HL,DE 43 | push HL 44 | pop DE ; En DE direccio VRAM 45 | pop HL ; En HL direccio RAM 46 | ld A,VRM_SPP_HIGH ; Bits A16-A14 47 | m_WRITE_DATA_REGISTER 0Eh ; Register 0Eh: VRAM access (VRAM address select, higher address lines) 48 | ld A,E ; Bits A7-A0 de direccio VRAM 49 | out (99h),A 50 | ld A,D ; Bits A13-A8 de direccio VRAM 51 | and 00111111b 52 | or 40h ; Desired VRAM Direction (0=Reading, 1=Writing) 53 | out (99h),A 54 | ld C,98h 55 | sla B ; Multiplica * 8 56 | sla B 57 | sla B 58 | .COPY_VRAM: 59 | outi 60 | inc B 61 | outi 62 | inc B 63 | outi 64 | inc B 65 | outi 66 | ; Sin esperas del VDP. Es MSX2 67 | jp nz,.COPY_VRAM 68 | ret 69 | -------------------------------------------------------------------------------- /LIB/MULT.GEN: -------------------------------------------------------------------------------- 1 | ;Rutines per multiplicar 2 | 3 | ;mul8b 4 | ;Multiplica dos factors de 8 bits, HL=B*C [Millor si B>1 14 | ret z 15 | sla C ; BC<<1 16 | rl B 17 | jr .LOOP 18 | 19 | ;mul8bf [mult fast] 20 | ;Multiplica dos factors de 8 bits, HL=B*C [Millor si B>1 35 | ret z 36 | sla C ; BC<<1 37 | rl B 38 | jr .LOOP 39 | -------------------------------------------------------------------------------- /LIB/N162ASC.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// N162ASC ////////////// 3 | ; //////////////////////////////// 4 | 5 | ; converteix numero 'HL' en ascii al buffer 'DE' 6 | 7 | ; HL = Numero a convertir 8 | ; DE = Posicion del Buffer del Numero [5 bytes] 9 | 10 | ; Cal RAM : res 11 | ; Toca : BC 12 | ; Retorna : a DE [en ASCII] 13 | ; Usa fun.: res 14 | 15 | N162ASC: 16 | ld BC,-10000 17 | call N162ASC_1 18 | ld BC,-1000 19 | call N162ASC_1 20 | ld BC,-100 21 | call N162ASC_1 22 | ld C,-10 23 | call N162ASC_1 24 | ld C,-1 25 | 26 | N162ASC_1: 27 | ld A,'0'-1 28 | N162ASC_2: 29 | inc A 30 | add HL,BC 31 | jr c,N162ASC_2 32 | sbc HL,BC 33 | ld (DE),A 34 | inc DE 35 | ret 36 | -------------------------------------------------------------------------------- /LIB/N2ASCII.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// N2ASCII ////////////// 3 | ; //////////////////////////////// 4 | 5 | ; converteix numero 'a' en ascii 'hl' (HEXADECIMAL) 6 | 7 | ; A = Numero a convertir 8 | 9 | ; Cal RAM : res 10 | ; Toca : B 11 | ; Retorna : HL (en Hexa. H=dece. L=unid.) 12 | ; Usa fun.: res 13 | 14 | N2ASCII: 15 | ld B,A 16 | and 00001111b 17 | cp 0Ah 18 | ; 19 | call nc,N2ASCII_0 20 | add A,30h 21 | ld L,A 22 | ld A,B 23 | srl A 24 | srl A 25 | srl A 26 | srl A 27 | cp 0Ah 28 | call nc,N2ASCII_0 29 | add A,30h 30 | ld H,A 31 | ret 32 | 33 | N2ASCII_0: 34 | add A,07h 35 | ret 36 | -------------------------------------------------------------------------------- /LIB/PSGMUTE.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// PSGMUTE ////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Apaga PSG 6 | 7 | ; Cal RAM : res 8 | ; Toca : res 9 | ; Retorna : res 10 | ; Usa fun.: res 11 | 12 | PSGMUTE: 13 | ld B,00111111b ; PSG -> Tot el Mixer OFF per 1 [R7] 14 | ld A,7 15 | out (0A0h),A 16 | in A,(0A2h) ; Lectura del R7 17 | and 11000000b ; Mascara para coger dos bits de joys 18 | or B ; mascara OR de B 19 | ld B,A 20 | ld A,7 ; Actualiza R7 del PSG 21 | out (0A0h),A 22 | ld A,B 23 | out (0A1h),A 24 | ld A,8 25 | out (0A0h),A ; PSG -> Canal A Volumen 0 (R8) 26 | xor A 27 | out (0A1h),A 28 | ld A,9 29 | out (0A0h),A ; PSG -> Canal B Volumen 0 (R9) 30 | xor A 31 | out (0A1h),A 32 | ld A,10 33 | out (0A0h),A ; PSG -> Canal C Volumen 0 (R10) 34 | xor A 35 | out (0A1h),A 36 | 37 | ret 38 | -------------------------------------------------------------------------------- /LIB/PT3PLAYER.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// PT3_SELECTMUSIC ////// 3 | ; //////////////////////////////// 4 | 5 | ; sets song to play 6 | 7 | ; HL = Song position 8 | 9 | ; Cal RAM : PT3_ON 10 | ; Toca : res 11 | ; Retorna : res 12 | ; Usa fun.: res 13 | 14 | PT3_SELECTMUSIC: 15 | push HL 16 | call PT3_STOP 17 | ld A,(PT3_SETUP) ; Sets Loop song, if 0 at bit0 18 | and 11111110b 19 | or 1b 20 | ld (PT3_SETUP),A 21 | ;CANCION 22 | pop HL ; hl <- initial address of module - 100 23 | call PT3_INIT ; Inits PT3 player 24 | ret 25 | 26 | PT3_STOP: 27 | xor A 28 | ld (PT3_ON),A 29 | call PT3_MUTE 30 | ret 31 | 32 | PT3_START: 33 | ld A,1 34 | ld (PT3_ON),A 35 | ret 36 | 37 | 38 | ; --- PT3 REPLAYER WORKING ON ROM --- 39 | ; --- Can be assembled with asMSX --- 40 | ; --- ROM version: MSX-KUN --- 41 | ; --- asMSX version: SapphiRe --- 42 | 43 | ; Based on MSX version of PT3 by KUN 44 | ; 45 | ; This version of the replayer uses a fixed volume and note table, if you need a 46 | ; different note table you can copy it from TABLES.TXT file, distributed with the 47 | ; original PT3 distribution. This version also allows the use of PT3 commands. 48 | ; 49 | ; PLAY and PSG WRITE routines seperated to allow independent calls 50 | ; 51 | ; ROM LENGTH: 1528 bytes 52 | ; RAM LENGTH: 382 bytes 53 | 54 | ; --- CONSTANT VALUES DEFINITION --- 55 | 56 | ;ChannelsVars 57 | ;struc CHNPRM 58 | ;reset group 59 | CHNPRM_PsInOr equ 0 ;RESB 1 60 | CHNPRM_PsInSm equ 1 ;RESB 1 61 | CHNPRM_CrAmSl equ 2 ;RESB 1 62 | CHNPRM_CrNsSl equ 3 ;RESB 1 63 | CHNPRM_CrEnSl equ 4 ;RESB 1 64 | CHNPRM_TSlCnt equ 5 ;RESB 1 65 | CHNPRM_CrTnSl equ 6 ;RESW 1 66 | CHNPRM_TnAcc equ 8 ;RESW 1 67 | CHNPRM_COnOff equ 10 ;RESB 1 68 | ;reset group 69 | 70 | CHNPRM_OnOffD equ 11 ;RESB 1 71 | 72 | ;IX for PTDECOD here (+12) 73 | CHNPRM_OffOnD equ 12 ;RESB 1 74 | CHNPRM_OrnPtr equ 13 ;RESW 1 75 | CHNPRM_SamPtr equ 15 ;RESW 1 76 | CHNPRM_NNtSkp equ 17 ;RESB 1 77 | CHNPRM_Note equ 18 ;RESB 1 78 | CHNPRM_SlToNt equ 19 ;RESB 1 79 | CHNPRM_Env_En equ 20 ;RESB 1 80 | CHNPRM_Flags equ 21 ;RESB 1 81 | ;Enabled - 0,SimpleGliss - 2 82 | CHNPRM_TnSlDl equ 22 ;RESB 1 83 | CHNPRM_TSlStp equ 23 ;RESW 1 84 | CHNPRM_TnDelt equ 25 ;RESW 1 85 | CHNPRM_NtSkCn equ 27 ;RESB 1 86 | CHNPRM_Volume equ 28 ;RESB 1 87 | CHNPRM_Size equ 29 ;RESB 1 88 | ;endstruc 89 | 90 | ;struc AR 91 | AR_TonA equ 0 ;RESW 1 92 | AR_TonB equ 2 ;RESW 1 93 | AR_TonC equ 4 ;RESW 1 94 | AR_Noise equ 6 ;RESB 1 95 | AR_Mixer equ 7 ;RESB 1 96 | AR_AmplA equ 8 ;RESB 1 97 | AR_AmplB equ 9 ;RESB 1 98 | AR_AmplC equ 10 ;RESB 1 99 | AR_Env equ 11 ;RESW 1 100 | AR_EnvTp equ 13 ;RESB 1 101 | ;endstruc 102 | 103 | ; --- CODE STARTS HERE --- 104 | 105 | CHECKLP: 106 | LD HL,PT3_SETUP 107 | SET 7,(HL) 108 | BIT 0,(HL) 109 | RET Z 110 | POP HL 111 | LD HL,DelyCnt 112 | INC (HL) 113 | LD HL,ChanA+CHNPRM_NtSkCn 114 | INC (HL) 115 | PT3_MUTE: XOR A 116 | LD H,A 117 | LD L,A 118 | LD (AYREGS+AR_AmplA),A 119 | LD (AYREGS+AR_AmplB),HL 120 | JP ROUT_A0 121 | 122 | PT3_INIT: ;HL - AddressOfModule - 100 123 | LD (PT3_MODADDR),HL 124 | PUSH HL 125 | LD DE,100 126 | ADD HL,DE 127 | LD A,(HL) 128 | LD (PT3_Delay),A 129 | PUSH HL 130 | POP IX 131 | ADD HL,DE 132 | LD (PT3_CrPsPtr),HL 133 | LD E,(IX+102-100) 134 | ADD HL,DE 135 | INC HL 136 | LD (PT3_LPosPtr),HL 137 | POP DE 138 | LD L,(IX+103-100) 139 | LD H,(IX+104-100) 140 | ADD HL,DE 141 | LD (PT3_PatsPtr),HL 142 | LD HL,169 143 | ADD HL,DE 144 | LD (PT3_OrnPtrs),HL 145 | LD HL,105 146 | ADD HL,DE 147 | LD (PT3_SAMPTRS),HL 148 | LD HL,PT3_SETUP 149 | RES 7,(HL) 150 | 151 | ; --- CREATE PT3 VOLUME TABLE [c] Ivan Roshin, adapted by SapphiRe --- 152 | ld hl,$11 153 | ld d,h 154 | ld e,h 155 | ld IX,VT_+16 156 | ld b,15 157 | .INITV1: push hl 158 | add hl,de 159 | ex de,hl 160 | sbc hl,hl 161 | ld c,b 162 | ld b,16 163 | .INITV2: ld a,l 164 | rla 165 | ld a,h 166 | adc a,0 167 | ld (ix),a 168 | inc ix 169 | add hl,de 170 | djnz .INITV2 171 | pop hl 172 | ld a,e 173 | cp $77 174 | jr nz,.INITV3 175 | inc e 176 | .INITV3: ld b,c 177 | djnz .INITV1 178 | 179 | ; --- INITIALIZE PT3 VARIABLES --- 180 | XOR A 181 | LD HL,VARS 182 | LD (HL),A 183 | LD DE,VARS+1 184 | LD BC,VAR0END-VARS-1 185 | LDIR 186 | 187 | INC A 188 | LD (DelyCnt),A 189 | LD HL,$F001 ;H - CHNPRM_Volume, L - CHNPRM_NtSkCn 190 | LD (ChanA+CHNPRM_NtSkCn),HL 191 | LD (ChanB+CHNPRM_NtSkCn),HL 192 | LD (ChanC+CHNPRM_NtSkCn),HL 193 | 194 | LD HL,EMPTYSAMORN 195 | LD (PT3_AdInPtA),HL ;ptr to zero 196 | LD (ChanA+CHNPRM_OrnPtr),HL ;ornament 0 is "0,1,0" 197 | LD (ChanB+CHNPRM_OrnPtr),HL ;in all versions from 198 | LD (ChanC+CHNPRM_OrnPtr),HL ;3.xx to 3.6x and VTII 199 | 200 | LD (ChanA+CHNPRM_SamPtr),HL ;S1 There is no default 201 | LD (ChanB+CHNPRM_SamPtr),HL ;S2 sample in PT3, so, you 202 | LD (ChanC+CHNPRM_SamPtr),HL ;S3 can comment S1,2,3; see 203 | ;also EMPTYSAMORN comment 204 | RET 205 | 206 | ;pattern decoder 207 | PD_OrSm: LD (IX+[CHNPRM_Env_En-12]),0 208 | CALL SETORN 209 | LD A,(BC) 210 | INC BC 211 | RRCA 212 | 213 | PD_SAM: ADD A,A 214 | PD_SAM_: LD E,A 215 | LD D,0 216 | LD HL,(PT3_SAMPTRS) 217 | ADD HL,DE 218 | LD E,(HL) 219 | INC HL 220 | LD D,(HL) 221 | LD HL,(PT3_MODADDR) 222 | ADD HL,DE 223 | LD (IX+[CHNPRM_SamPtr-12]),L 224 | LD (IX+[CHNPRM_SamPtr+1-12]),H 225 | JR PD_LOOP 226 | 227 | PD_VOL: RLCA 228 | RLCA 229 | RLCA 230 | RLCA 231 | LD (IX+[CHNPRM_Volume-12]),A 232 | JR PD_LP2 233 | 234 | PD_EOff: LD (IX+[CHNPRM_Env_En-12]),A 235 | LD (IX+[CHNPRM_PsInOr-12]),A 236 | JR PD_LP2 237 | 238 | PD_SorE: DEC A 239 | JR NZ,PD_ENV 240 | LD A,(BC) 241 | INC BC 242 | LD (IX+[CHNPRM_NNtSkp-12]),A 243 | JR PD_LP2 244 | 245 | PD_ENV: CALL SETENV 246 | JR PD_LP2 247 | 248 | PD_ORN: CALL SETORN 249 | JR PD_LOOP 250 | 251 | PD_ESAM: LD (IX+[CHNPRM_Env_En-12]),A 252 | LD (IX+[CHNPRM_PsInOr-12]),A 253 | CALL NZ,SETENV 254 | LD A,(BC) 255 | INC BC 256 | JR PD_SAM_ 257 | 258 | PTDECOD: LD A,(IX+[CHNPRM_Note-12]) 259 | LD (PT3_PrNote),A 260 | LD L,(IX+[CHNPRM_CrTnSl-12]) 261 | LD H,(IX+[CHNPRM_CrTnSl+1-12]) 262 | LD (PT3_PrSlide),HL 263 | 264 | PD_LOOP: LD DE,$2010 265 | PD_LP2: LD A,(BC) 266 | INC BC 267 | ADD A,E 268 | JR C,PD_OrSm 269 | ADD A,D 270 | JR Z,PD_FIN 271 | JR C,PD_SAM 272 | ADD A,E 273 | JR Z,PD_REL 274 | JR C,PD_VOL 275 | ADD A,E 276 | JR Z,PD_EOff 277 | JR C,PD_SorE 278 | ADD A,96 279 | JR C,PD_NOTE 280 | ADD A,E 281 | JR C,PD_ORN 282 | ADD A,D 283 | JR C,PD_NOIS 284 | ADD A,E 285 | JR C,PD_ESAM 286 | ADD A,A 287 | LD E,A 288 | LD HL,[[SPCCOMS+$DF20] % 65536] ; Adapted from original Speccy version [saves 6 bytes] 289 | ADD HL,DE 290 | LD E,(HL) 291 | INC HL 292 | LD D,(HL) 293 | PUSH DE 294 | JR PD_LOOP 295 | 296 | PD_NOIS: LD (Ns_Base),A 297 | JR PD_LP2 298 | 299 | PD_REL: RES 0,(IX+[CHNPRM_Flags-12]) 300 | JR PD_RES 301 | 302 | PD_NOTE: LD (IX+[CHNPRM_Note-12]),A 303 | SET 0,(IX+[CHNPRM_Flags-12]) 304 | XOR A 305 | 306 | PD_RES: LD (PT3_PDSP),SP 307 | LD SP,IX 308 | LD H,A 309 | LD L,A 310 | PUSH HL 311 | PUSH HL 312 | PUSH HL 313 | PUSH HL 314 | PUSH HL 315 | PUSH HL 316 | LD SP,(PT3_PDSP) 317 | 318 | PD_FIN: LD A,(IX+[CHNPRM_NNtSkp-12]) 319 | LD (IX+[CHNPRM_NtSkCn-12]),A 320 | RET 321 | 322 | C_PORTM: RES 2,(IX+[CHNPRM_Flags-12]) 323 | LD A,(BC) 324 | INC BC 325 | ;SKIP PRECALCULATED TONE DELTA (BECAUSE 326 | ;CANNOT BE RIGHT AFTER PT3 COMPILATION) 327 | INC BC 328 | INC BC 329 | LD (IX+[CHNPRM_TnSlDl-12]),A 330 | LD (IX+[CHNPRM_TSlCnt-12]),A 331 | LD DE,NT_ 332 | LD A,(IX+[CHNPRM_Note-12]) 333 | LD (IX+[CHNPRM_SlToNt-12]),A 334 | ADD A,A 335 | LD L,A 336 | LD H,0 337 | ADD HL,DE 338 | LD A,(HL) 339 | INC HL 340 | LD H,(HL) 341 | LD L,A 342 | PUSH HL 343 | LD A,(PT3_PrNote) 344 | LD (IX+[CHNPRM_Note-12]),A 345 | ADD A,A 346 | LD L,A 347 | LD H,0 348 | ADD HL,DE 349 | LD E,(HL) 350 | INC HL 351 | LD D,(HL) 352 | POP HL 353 | SBC HL,DE 354 | LD (IX+[CHNPRM_TnDelt-12]),L 355 | LD (IX+[CHNPRM_TnDelt+1-12]),H 356 | LD DE,(PT3_PrSlide) 357 | LD (IX+[CHNPRM_CrTnSl-12]),E 358 | LD (IX+[CHNPRM_CrTnSl+1-12]),D 359 | LD A,(BC) ;SIGNED TONE STEP 360 | INC BC 361 | EX AF,AF' 362 | LD A,(BC) 363 | INC BC 364 | AND A 365 | JR Z,.NOSIG 366 | EX DE,HL 367 | .NOSIG: SBC HL,DE 368 | JP P,SET_STP 369 | CPL 370 | EX AF,AF' 371 | NEG 372 | EX AF,AF' 373 | SET_STP: LD (IX+[CHNPRM_TSlStp+1-12]),A 374 | EX AF,AF' 375 | LD (IX+[CHNPRM_TSlStp-12]),A 376 | LD (IX+[CHNPRM_COnOff-12]),0 377 | RET 378 | 379 | C_GLISS: SET 2,(IX+[CHNPRM_Flags-12]) 380 | LD A,(BC) 381 | INC BC 382 | LD (IX+[CHNPRM_TnSlDl-12]),A 383 | LD (IX+[CHNPRM_TSlCnt-12]),A 384 | LD A,(BC) 385 | INC BC 386 | EX AF,AF' 387 | LD A,(BC) 388 | INC BC 389 | JR SET_STP 390 | 391 | C_SMPOS: LD A,(BC) 392 | INC BC 393 | LD (IX+[CHNPRM_PsInSm-12]),A 394 | RET 395 | 396 | C_ORPOS: LD A,(BC) 397 | INC BC 398 | LD (IX+[CHNPRM_PsInOr-12]),A 399 | RET 400 | 401 | C_VIBRT: LD A,(BC) 402 | INC BC 403 | LD (IX+[CHNPRM_OnOffD-12]),A 404 | LD (IX+[CHNPRM_COnOff-12]),A 405 | LD A,(BC) 406 | INC BC 407 | LD (IX+[CHNPRM_OffOnD-12]),A 408 | XOR A 409 | LD (IX+[CHNPRM_TSlCnt-12]),A 410 | LD (IX+[CHNPRM_CrTnSl-12]),A 411 | LD (IX+[CHNPRM_CrTnSl+1-12]),A 412 | RET 413 | 414 | C_ENGLS: LD A,(BC) 415 | INC BC 416 | LD (PT3_Env_Del),A 417 | LD (CurEDel),A 418 | LD A,(BC) 419 | INC BC 420 | LD L,A 421 | LD A,(BC) 422 | INC BC 423 | LD H,A 424 | LD (PT3_ESldAdd),HL 425 | RET 426 | 427 | C_DELAY: LD A,(BC) 428 | INC BC 429 | LD (PT3_Delay),A 430 | RET 431 | 432 | SETENV: LD (IX+[CHNPRM_Env_En-12]),E 433 | LD (AYREGS+AR_EnvTp),A 434 | LD A,(BC) 435 | INC BC 436 | LD H,A 437 | LD A,(BC) 438 | INC BC 439 | LD L,A 440 | LD (EnvBase),HL 441 | XOR A 442 | LD (IX+[CHNPRM_PsInOr-12]),A 443 | LD (CurEDel),A 444 | LD H,A 445 | LD L,A 446 | LD (CurESld),HL 447 | C_NOP: RET 448 | 449 | SETORN: ADD A,A 450 | LD E,A 451 | LD D,0 452 | LD (IX+[CHNPRM_PsInOr-12]),D 453 | LD HL,(PT3_OrnPtrs) 454 | ADD HL,DE 455 | LD E,(HL) 456 | INC HL 457 | LD D,(HL) 458 | LD HL,(PT3_MODADDR) 459 | ADD HL,DE 460 | LD (IX+[CHNPRM_OrnPtr-12]),L 461 | LD (IX+[CHNPRM_OrnPtr+1-12]),H 462 | RET 463 | 464 | ;ALL 16 ADDRESSES TO PROTECT FROM BROKEN PT3 MODULES 465 | SPCCOMS: dw C_NOP 466 | dw C_GLISS 467 | dw C_PORTM 468 | dw C_SMPOS 469 | dw C_ORPOS 470 | dw C_VIBRT 471 | dw C_NOP 472 | dw C_NOP 473 | dw C_ENGLS 474 | dw C_DELAY 475 | dw C_NOP 476 | dw C_NOP 477 | dw C_NOP 478 | dw C_NOP 479 | dw C_NOP 480 | dw C_NOP 481 | 482 | CHREGS: XOR A 483 | LD (AYREGS+AR_AmplC),A 484 | BIT 0,(IX+CHNPRM_Flags) 485 | PUSH HL 486 | JP Z,.CH_EXIT 487 | LD (PT3_CSP),SP 488 | LD L,(IX+CHNPRM_OrnPtr) 489 | LD H,(IX+CHNPRM_OrnPtr+1) 490 | LD SP,HL 491 | POP DE 492 | LD H,A 493 | LD A,(IX+CHNPRM_PsInOr) 494 | LD L,A 495 | ADD HL,SP 496 | INC A 497 | CP D 498 | JR C,.CH_ORPS 499 | LD A,E 500 | .CH_ORPS: LD (IX+CHNPRM_PsInOr),A 501 | LD A,(IX+CHNPRM_Note) 502 | ADD A,(HL) 503 | JP P,.CH_NTP 504 | XOR A 505 | .CH_NTP: CP 96 506 | JR C,.CH_NOK 507 | LD A,95 508 | .CH_NOK: ADD A,A 509 | EX AF,AF' 510 | LD L,(IX+CHNPRM_SamPtr) 511 | LD H,(IX+CHNPRM_SamPtr+1) 512 | LD SP,HL 513 | POP DE 514 | LD H,0 515 | LD A,(IX+CHNPRM_PsInSm) 516 | LD B,A 517 | ADD A,A 518 | ADD A,A 519 | LD L,A 520 | ADD HL,SP 521 | LD SP,HL 522 | LD A,B 523 | INC A 524 | CP D 525 | JR C,.CH_SMPS 526 | LD A,E 527 | .CH_SMPS: LD (IX+CHNPRM_PsInSm),A 528 | POP BC 529 | POP HL 530 | LD E,(IX+CHNPRM_TnAcc) 531 | LD D,(IX+CHNPRM_TnAcc+1) 532 | ADD HL,DE 533 | BIT 6,B 534 | JR Z,.CH_NOAC 535 | LD (IX+CHNPRM_TnAcc),L 536 | LD (IX+CHNPRM_TnAcc+1),H 537 | .CH_NOAC: EX DE,HL 538 | EX AF,AF' 539 | LD L,A 540 | LD H,0 541 | LD SP,NT_ 542 | ADD HL,SP 543 | LD SP,HL 544 | POP HL 545 | ADD HL,DE 546 | LD E,(IX+CHNPRM_CrTnSl) 547 | LD D,(IX+CHNPRM_CrTnSl+1) 548 | ADD HL,DE 549 | LD SP,(PT3_CSP) 550 | EX (SP),HL 551 | XOR A 552 | OR (IX+CHNPRM_TSlCnt) 553 | JR Z,.CH_AMP 554 | DEC (IX+CHNPRM_TSlCnt) 555 | JR NZ,.CH_AMP 556 | LD A,(IX+CHNPRM_TnSlDl) 557 | LD (IX+CHNPRM_TSlCnt),A 558 | LD L,(IX+CHNPRM_TSlStp) 559 | LD H,(IX+CHNPRM_TSlStp+1) 560 | LD A,H 561 | ADD HL,DE 562 | LD (IX+CHNPRM_CrTnSl),L 563 | LD (IX+CHNPRM_CrTnSl+1),H 564 | BIT 2,(IX+CHNPRM_Flags) 565 | JR NZ,.CH_AMP 566 | LD E,(IX+CHNPRM_TnDelt) 567 | LD D,(IX+CHNPRM_TnDelt+1) 568 | AND A 569 | JR Z,.CH_STPP 570 | EX DE,HL 571 | .CH_STPP: SBC HL,DE 572 | JP M,.CH_AMP 573 | LD A,(IX+CHNPRM_SlToNt) 574 | LD (IX+CHNPRM_Note),A 575 | XOR A 576 | LD (IX+CHNPRM_TSlCnt),A 577 | LD (IX+CHNPRM_CrTnSl),A 578 | LD (IX+CHNPRM_CrTnSl+1),A 579 | .CH_AMP: LD A,(IX+CHNPRM_CrAmSl) 580 | BIT 7,C 581 | JR Z,.CH_NOAM 582 | BIT 6,C 583 | JR Z,.CH_AMIN 584 | CP 15 585 | JR Z,.CH_NOAM 586 | INC A 587 | JR .CH_SVAM 588 | .CH_AMIN: CP -15 589 | JR Z,.CH_NOAM 590 | DEC A 591 | .CH_SVAM: LD (IX+CHNPRM_CrAmSl),A 592 | .CH_NOAM: LD L,A 593 | LD A,B 594 | AND 15 595 | ADD A,L 596 | JP P,.CH_APOS 597 | XOR A 598 | .CH_APOS: CP 16 599 | JR C,.CH_VOL 600 | LD A,15 601 | .CH_VOL: OR (IX+CHNPRM_Volume) 602 | LD L,A 603 | LD H,0 604 | LD DE,VT_ 605 | ADD HL,DE 606 | LD A,(HL) 607 | .CH_ENV: BIT 0,C 608 | JR NZ,.CH_NOEN 609 | OR (IX+CHNPRM_Env_En) 610 | .CH_NOEN: LD (AYREGS+AR_AmplC),A 611 | BIT 7,B 612 | LD A,C 613 | JR Z,.NO_ENSL 614 | RLA 615 | RLA 616 | SRA A 617 | SRA A 618 | SRA A 619 | ADD A,(IX+CHNPRM_CrEnSl) ;SEE COMMENT BELOW 620 | BIT 5,B 621 | JR Z,.NO_ENAC 622 | LD (IX+CHNPRM_CrEnSl),A 623 | .NO_ENAC: LD HL,PT3_AddToEn 624 | ADD A,(HL) ;BUG IN PT3 - NEED WORD HERE. 625 | ;FIX IT IN NEXT VERSION? 626 | LD (HL),A 627 | JR .CH_MIX 628 | .NO_ENSL: RRA 629 | ADD A,(IX+CHNPRM_CrNsSl) 630 | LD (AddToNs),A 631 | BIT 5,B 632 | JR Z,.CH_MIX 633 | LD (IX+CHNPRM_CrNsSl),A 634 | .CH_MIX: LD A,B 635 | RRA 636 | AND $48 637 | .CH_EXIT: LD HL,AYREGS+AR_Mixer 638 | OR (HL) 639 | RRCA 640 | LD (HL),A 641 | POP HL 642 | XOR A 643 | OR (IX+CHNPRM_COnOff) 644 | RET Z 645 | DEC (IX+CHNPRM_COnOff) 646 | RET NZ 647 | XOR (IX+CHNPRM_Flags) 648 | LD (IX+CHNPRM_Flags),A 649 | RRA 650 | LD A,(IX+CHNPRM_OnOffD) 651 | JR C,.CH_ONDL 652 | LD A,(IX+CHNPRM_OffOnD) 653 | .CH_ONDL: LD (IX+CHNPRM_COnOff),A 654 | RET 655 | 656 | PT3_PLAY: 657 | XOR A 658 | LD (PT3_AddToEn),A 659 | LD (AYREGS+AR_Mixer),A 660 | DEC A 661 | LD (AYREGS+AR_EnvTp),A 662 | LD HL,DelyCnt 663 | DEC (HL) 664 | JP NZ,.PL2 665 | LD HL,ChanA+CHNPRM_NtSkCn 666 | DEC (HL) 667 | JR NZ,.PL1B 668 | LD BC,(PT3_AdInPtA) 669 | LD A,(BC) 670 | AND A 671 | JR NZ,.PL1A 672 | LD D,A 673 | LD (Ns_Base),A 674 | LD HL,(PT3_CrPsPtr) 675 | INC HL 676 | LD A,(HL) 677 | INC A 678 | JR NZ,.PLNLP 679 | CALL CHECKLP 680 | LD HL,(PT3_LPosPtr) 681 | LD A,(HL) 682 | INC A 683 | .PLNLP: LD (PT3_CrPsPtr),HL 684 | 685 | ;; Add by Jamque 686 | push HL 687 | push DE 688 | push AF 689 | ld HL,(PT3_CrPsPtr) 690 | ld DE, -0x0C9 691 | add HL,DE 692 | ld DE,(PT3_MODADDR) 693 | xor A ; Clear Carry 694 | sbc HL,DE 695 | ld A,L 696 | ld (PT3_PATTERN_POS),A 697 | xor A 698 | ld (PT3_SECOND),A 699 | ld (PT3_FRAME),A 700 | pop AF 701 | pop DE 702 | pop HL 703 | 704 | DEC A 705 | ADD A,A 706 | LD E,A 707 | RL D 708 | LD HL,(PT3_PatsPtr) 709 | ADD HL,DE 710 | LD DE,(PT3_MODADDR) 711 | LD (PT3_PSP),SP 712 | LD SP,HL 713 | POP HL 714 | ADD HL,DE 715 | LD B,H 716 | LD C,L 717 | POP HL 718 | ADD HL,DE 719 | LD (PT3_AdInPtB),HL 720 | POP HL 721 | ADD HL,DE 722 | LD (PT3_AdInPtC),HL 723 | LD SP,(PT3_PSP) 724 | 725 | .PL1A: LD IX,ChanA+12 726 | CALL PTDECOD 727 | LD (PT3_AdInPtA),BC 728 | 729 | .PL1B: LD HL,ChanB+CHNPRM_NtSkCn 730 | DEC (HL) 731 | JR NZ,.PL1C 732 | LD IX,ChanB+12 733 | LD BC,(PT3_AdInPtB) 734 | CALL PTDECOD 735 | LD (PT3_AdInPtB),BC 736 | 737 | .PL1C: LD HL,ChanC+CHNPRM_NtSkCn 738 | DEC (HL) 739 | JR NZ,.PL1D 740 | LD IX,ChanC+12 741 | LD BC,(PT3_AdInPtC) 742 | CALL PTDECOD 743 | LD (PT3_AdInPtC),BC 744 | 745 | .PL1D: LD A,(PT3_Delay) 746 | LD (DelyCnt),A 747 | 748 | .PL2: LD IX,ChanA 749 | LD HL,(AYREGS+AR_TonA) 750 | CALL CHREGS 751 | LD (AYREGS+AR_TonA),HL 752 | LD A,(AYREGS+AR_AmplC) 753 | LD (AYREGS+AR_AmplA),A 754 | LD IX,ChanB 755 | LD HL,(AYREGS+AR_TonB) 756 | CALL CHREGS 757 | LD (AYREGS+AR_TonB),HL 758 | LD A,(AYREGS+AR_AmplC) 759 | LD (AYREGS+AR_AmplB),A 760 | LD IX,ChanC 761 | LD HL,(AYREGS+AR_TonC) 762 | CALL CHREGS 763 | LD (AYREGS+AR_TonC),HL 764 | 765 | LD HL,(Ns_Base_AddToNs) 766 | LD A,H 767 | ADD A,L 768 | LD (AYREGS+AR_Noise),A 769 | 770 | LD A,(PT3_AddToEn) 771 | LD E,A 772 | ADD A,A 773 | SBC A,A 774 | LD D,A 775 | LD HL,(EnvBase) 776 | ADD HL,DE 777 | LD DE,(CurESld) 778 | ADD HL,DE 779 | LD (AYREGS+AR_Env),HL 780 | 781 | XOR A 782 | LD HL,CurEDel 783 | OR (HL) 784 | RET Z 785 | DEC (HL) 786 | RET NZ 787 | LD A,(PT3_Env_Del) 788 | LD (HL),A 789 | LD HL,(PT3_ESldAdd) 790 | ADD HL,DE 791 | LD (CurESld),HL 792 | RET 793 | 794 | PT3_ROUT: XOR A 795 | 796 | ROUT_A0: ; --- FIXES BITS 6 AND 7 OF MIXER --- 797 | LD HL,AYREGS+AR_Mixer 798 | set 7,(hl) 799 | res 6,(hl) 800 | 801 | LD C,$A0 802 | LD HL,AYREGS 803 | .LOUT: OUT (C),A 804 | INC C 805 | OUTI 806 | DEC C 807 | INC A 808 | CP 13 809 | JR NZ,.LOUT 810 | OUT (C),A 811 | LD A,(HL) 812 | AND A 813 | RET M 814 | INC C 815 | OUT (C),A 816 | RET 817 | 818 | EMPTYSAMORN: db 0,1,0,$90 ;delete $90 if you don't need default sample 819 | 820 | NT_: ;Note table 2 (if you use another in Vortex Tracker II copy it and paste 821 | ;it from TABLES.TXT) 822 | 823 | dw $0D10,$0C55,$0BA4,$0AFC,$0A5F,$09CA,$093D,$08B8,$083B,$07C5,$0755,$06EC 824 | dw $0688,$062A,$05D2,$057E,$052F,$04E5,$049E,$045C,$041D,$03E2,$03AB,$0376 825 | dw $0344,$0315,$02E9,$02BF,$0298,$0272,$024F,$022E,$020F,$01F1,$01D5,$01BB 826 | dw $01A2,$018B,$0174,$0160,$014C,$0139,$0128,$0117,$0107,$00F9,$00EB,$00DD 827 | dw $00D1,$00C5,$00BA,$00B0,$00A6,$009D,$0094,$008C,$0084,$007C,$0075,$006F 828 | dw $0069,$0063,$005D,$0058,$0053,$004E,$004A,$0046,$0042,$003E,$003B,$0037 829 | dw $0034,$0031,$002F,$002C,$0029,$0027,$0025,$0023,$0021,$001F,$001D,$001C 830 | dw $001A,$0019,$0017,$0016,$0015,$0014,$0012,$0011,$0010,$000F,$000E,$000D 831 | -------------------------------------------------------------------------------- /LIB/PUTGFX.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/PUTGFX.GEN -------------------------------------------------------------------------------- /LIB/PUTGFX_TILETRANS.GEN: -------------------------------------------------------------------------------- 1 | ; Rutines per posar/copiar Grafics de tiles 2 | ; on els dos primers bytes indiquen la mida que tenen 3 | ; 4 | ; PUTGFX : Posa Grafic a RAM BUFFER DE VIDEO 5 | ; /////////////////////////////////////////////// 6 | ; ///////// PUTGFX with TILE TRANSPARENT //////// 7 | ; /////////////////////////////////////////////// 8 | ; Posa un GFX de tiles en una posicio determinada del BUFFER a RAM 9 | ; IX = direccio RAM del GFX [2 BYTES ALÇADA i AMPLE] 10 | ; IY = direccion RAM del BUFFER desti 11 | ; C = ID de tile tranparent. No es pintara 12 | 13 | ; Cal RAM : res 14 | ; Toca : A,BC,DE,HL,IX,IY 15 | ; Retorna : res 16 | ; Usa fun.: res 17 | PUTGFX_TRANS: 18 | ; Carrego quantes lineas 19 | ld A,(IX) 20 | ld B,A ; Preparo contador 21 | inc IX 22 | ; Carrego quantes tiles d'ample 23 | ld A,(IX) 24 | ld E,A 25 | inc IX 26 | .LOOPFILA: 27 | push BC 28 | ld B,E ; Numero de tiles 29 | .LOOPTILE: 30 | ld A,(IX) ; Copio una tile 31 | cp C 32 | jr z,.NOPINTA 33 | ld (IY),A 34 | .NOPINTA: 35 | inc IX 36 | inc IY 37 | djnz .LOOPTILE 38 | ld A,32 39 | sub E ; 32-Numero de tiles es el incremento de IY 40 | ld C,A 41 | add IY,BC 42 | pop BC 43 | djnz .LOOPFILA 44 | 45 | ret 46 | 47 | -------------------------------------------------------------------------------- /LIB/RANDOM.GEN: -------------------------------------------------------------------------------- 1 | ;Random mes real 2 | 3 | ; ////////////////////////////// 4 | ; ///////// GET_RANDOM ///////// 5 | ; ////////////////////////////// 6 | 7 | ; Genera un numero aleatori de 0 a 255 8 | ; Original de : 9 | ; http://www.smspower.org/Development/RandomNumberGenerator 10 | 11 | ; Cal RAM : TIMER 12 | ; Toca : HL 13 | ; Param : 14 | ; Retorna : A = RND % 256 15 | ; Usa fun.: 16 | 17 | GET_RANDOM: 18 | push HL 19 | ld HL,(TIM_RND) 20 | ld A,H ; get high byte 21 | rrca ; rotate right by 2 22 | rrca 23 | xor H ; xor with original 24 | rrca ; rotate right by 1 25 | xor L ; xor with low byte 26 | rrca ; rotate right by 4 27 | rrca 28 | rrca 29 | rrca 30 | xor L ; xor again 31 | rra ; rotate right by 1 through carry 32 | adc HL,HL ; add TIM_RND to itself 33 | jr nz,.ADD 34 | ld HL,733Ch ; if last xor resulted in zero then re-seed random number generator 35 | .ADD: 36 | jr TIM_RNDSEEDINIT_FROM_GET 37 | 38 | ; ////////////////////////////// 39 | ; ////// TIM_RNDSEEDINIT /////// 40 | ; ////////////////////////////// 41 | 42 | ; Reinicia la llavor del random amb el número R 43 | ; Si es crida en llocs que no sempre triga el mateix a passar, 44 | ; queda força realista. 45 | 46 | TIM_RNDSEEDINIT: 47 | push HL 48 | ld HL,(TIM_RND) 49 | 50 | TIM_RNDSEEDINIT_FROM_GET: 51 | ld A,R ; R = refresh register = semi-random number 52 | xor L ; xor with l which is fairly random 53 | ld (TIM_RND),HL 54 | pop HL 55 | 56 | ret 57 | -------------------------------------------------------------------------------- /LIB/SCREEN.GEN: -------------------------------------------------------------------------------- 1 | ; ///////////////////////////// 2 | ; //////// SCREEN ///////////// 3 | ; ///////////////////////////// 4 | 5 | ; Posa Screen A i mode de Sprites 16 no ampliat 6 | 7 | ; A = Modo de Screen deseado 8 | 9 | ; Cal RAM : MACROSVDP.ASM 10 | ; Toca : IX,IY 11 | ; Retorna : res 12 | ; Usa fun.: BIOS call interslot 13 | 14 | SCREEN_BIOS EQU 05Fh 15 | EXPTBL EQU 0FCC1h 16 | 17 | SCREEN: 18 | ld IY,(EXPTBL-1) 19 | ld IX,SCREEN_BIOS 20 | call CALSLT 21 | ; Init Registers 22 | ; RG(0-7)SAV #F3DF #F3E6 23 | ld BC, 8 24 | ld HL, 0F3DFh 25 | ld DE, VDP_REG 26 | ldir 27 | ; RG(8-23)SAV #FFE7 #FFF6 28 | ld BC, 16 29 | ld HL, 0FFE7h 30 | ld DE, VDP_REG+8 31 | ldir 32 | 33 | ld A,1 34 | m_WRITE_DATA_REGISTER 07h ; Register 7: colour register. 35 | 36 | ; 0 bit 0 Zoom x1 0 37 | ; 1 bit 1 Sprites de 16x16 38 | ; 1 bit 5 V-Blank Enable 39 | ; 1 bit 6 Screen Enable 40 | ld A,(VDP_REG+1) 41 | and 11111110b ; 0 bit 0 Zoom x1 0 42 | or 01100010b ; los bits 1 5 6 43 | m_WRITE_DATA_REGISTER 01h ; Register 1: Mode register 1 44 | ret 45 | 46 | ; Apaga la pantalla 47 | ; Requereix interrupcions deshabilitades 48 | SCREEN_OFF: 49 | ld A,(VDP_REG+1) 50 | ; 6 BLK Screen output control (0=Disable, 1=Enable) 51 | and 10111111b ; Screen Disable 52 | ld (VDP_REG+1),A 53 | m_WRITE_DATA_REGISTER 01h ; Register 1: Mode register 1 54 | ret 55 | 56 | ; Encen la pantalla 57 | ; Requereix interrupcions deshabilitades 58 | SCREEN_ON: 59 | ld A,(VDP_REG+1) 60 | ; 6 BLK Screen output control (0=Disable, 1=Enable) 61 | or 01000000b ; Screen Enable 62 | ld (VDP_REG+1),A 63 | m_WRITE_DATA_REGISTER 01h ; Register 1: Mode register 1 64 | ret 65 | -------------------------------------------------------------------------------- /LIB/SET48K.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; //////// SET48K ///////////// 3 | ; //////////////////////////////// 4 | 5 | SET48K: 6 | call SETPAGES32K 7 | call setrompage0 8 | ret 9 | 10 | ; ----------------------------------------------------- 11 | ; --- RUTINAS PARA COLOCAR LAS PAGINAS DEL CARTUCHO --- 12 | ; ----------------------------------------------------- 13 | ; --- SIEMPRE DEBEN IR EN LA PAGINA 1 DEL CARTUCHO! --- 14 | ; ----------------------------------------------------- 15 | ; --- RUTINAS PRINCIPALES DEL MODULO --- 16 | ; GETSLOT: OBTIENE EL VALOR DEL SLOT QUE LE INDIQUEMOS 17 | ; SETPAGES32K: BIOS-ROM-YY-ZZ -> BIOS-ROM-ROM-ZZ [SITUA PAGINA 2] 18 | ; --- VARIABLES EN RAM NECESARIAS --- 19 | ; NINGUNA 20 | GETSLOT: 21 | ; --- Rutina que construye el valor del SLOT para llamar a ENASLT --- 22 | ; --- Entrada: a = SLOT --- 23 | ; --- Salida: a = valor para ENASLT --- 24 | ; --- AUTOR: Konamiman --- 25 | and 03h ; Proteccion, nos aseguramos de que el valor esta en 0-3 26 | ld c,a ; c = slot de la pagina 27 | ld b,0 ; bc = slot de la pagina 28 | ld hl,0FCC1h ; Tabla de slots expandidos 29 | add hl,bc ; hl -> variable que indica si este slot esta expandido 30 | ld a,(hl) ; Tomamos el valor 31 | and 80h ; Si el bit mas alto es cero... 32 | jr z,.EXIT ; ...nos vamos a .EXIT 33 | ; --- El slot esta expandido --- 34 | or c ; Slot basico en el lugar adecuado 35 | ld c,a ; Guardamos el valor en c 36 | inc hl ; Incrementamos hl una... 37 | inc hl ; ...dos... 38 | inc hl ; ...tres... 39 | inc hl ; ...cuatro veces 40 | ld a,(hl) ; a = valor del registro de subslot 41 | ; del slot donde estamos 42 | and 0Ch ; Nos quedamos con el valor donde esta nuestro cartucho 43 | .EXIT: 44 | or c ; Slot extendido/basico en su lugar 45 | ret ; Volvemos 46 | 47 | SETPAGES32K: ; --- Posiciona las paginas de un megarom o un 32K --- 48 | ld a,0C9h ; Codigo de RET 49 | ld (.NOPRET),a ; Modificamos la siguiente instruccion 50 | ; si estamos en RAM 51 | .NOPRET: nop ; No hacemos nada si no estamos en RAM 52 | ; --- Si llegamos aqui no estamos en RAM, hay que posicionar la pagina --- 53 | call RSLREG ; Leemos el contenido del registro de seleccion de slots 54 | rrca ; Rotamos a la derecha... 55 | rrca ; ...dos veces 56 | call GETSLOT ; Obtenemos el slot de la pagina 1 [4000-0BFFFh] 57 | ld h,80h ; Seleccionamos pagina 2 [8000h-0BFFFh] 58 | jp ENASLT ; Posicionamos la pagina 2 y volvemos 59 | 60 | ; ----------------------- 61 | ; SEARCH_SLOTSET 62 | ; Posiciona en pagina 2 63 | ; Nuestro ROM. 64 | ; ----------------------- 65 | 66 | search_slotset: 67 | call search_slot 68 | jp ENASLT 69 | 70 | 71 | ; ----------------------- 72 | ; SEARCH_SLOT 73 | ; Busca slot de nuestro rom 74 | ; ----------------------- 75 | 76 | search_slot: 77 | call RSLREG 78 | rrca 79 | rrca 80 | and 3 81 | ld c,a 82 | ld b,0 83 | ld hl,0FCC1h 84 | add hl,bc 85 | ld a,(hl) 86 | and 080h 87 | or c 88 | ld c,a 89 | inc hl 90 | inc hl 91 | inc hl 92 | inc hl 93 | ld a,(hl) 94 | and 0Ch 95 | or c; 96 | ld h,080h 97 | ld (slotvar),a 98 | ret 99 | 100 | ; ------------------------------ 101 | ; SETROMPAGE0 102 | ; Posiciona nuestro cartucho en 103 | ; Pagina 0 104 | ; ----------------------------- 105 | 106 | setrompage0: 107 | ; call GETSLOT 108 | call search_slotset 109 | ld a,(slotvar) 110 | jr setslotpage0 111 | ; ------------------------------ 112 | ; RECBIOS 113 | ; Posiciona la bios ROM 114 | ; ------------------------------- 115 | recbios: 116 | ld a,(EXPTBL) 117 | ; --------------------------- 118 | ; SETSLOTPAGE0 119 | ; Posiciona el slot pasado 120 | ; en pagina 0 del Z80 121 | ; A: Formato FxxxSSPP 122 | ; ---------------------------- 123 | 124 | setslotpage0: 125 | di 126 | ld b,a ; B = Slot param in FxxxSSPP format 127 | in a,(0A8h) 128 | and 011111100b 129 | ld d,a ; D = Primary slot value 130 | ld a,b 131 | and 03 132 | or d 133 | ld d,a ; D = Final Value for primary slot 134 | ; Check if expanded 135 | ld a,b 136 | bit 7,a 137 | jr z,recbiosprimary ; Not Expanded 138 | and 03h 139 | rrca 140 | rrca 141 | and 011000000b 142 | ld c,a 143 | ld a,d 144 | and 00111111b 145 | or c 146 | ld c,a ; Primary slot value with main slot in page 3 147 | ld a,b 148 | and 00001100b 149 | rrca 150 | rrca 151 | and 03h 152 | ld b,a ; B = Expanded slot in page 3 153 | ld a,c 154 | out (0A8h),a ; Slot : Main Slot, xx, xx, Main slot 155 | ld a,(0FFFFh) 156 | cpl 157 | and 011111100b 158 | or b 159 | ld (0FFFFh),a ; Expanded slot selected 160 | 161 | recbiosprimary: 162 | ld a,d ; A = Final value 163 | out (0A8h),a 164 | ; Slot Final. Ram, rom c, rom c, Main 165 | ret 166 | -------------------------------------------------------------------------------- /LIB/SETPAGEVIEW.GEN: -------------------------------------------------------------------------------- 1 | ; ////////////////////////////////////// 2 | ; ///////// SETPAGEVIEW //////////////// 3 | ; ////////////////////////////////////// 4 | ; MSX2 5 | ; Posa visible el numero de pagina seleccionat 6 | 7 | ; A = Pagina Visible (0-3) 8 | 9 | SETPAGEVIEW: ; Envio a REG 2 0XX1 1111 10 | sla A 11 | sla A 12 | sla A 13 | sla A 14 | sla A 15 | or 00011111b 16 | out (099h),A 17 | ld A,80h+02h ; Reg 2 Bitmap Table 18 | out (099h),A 19 | 20 | ret 21 | -------------------------------------------------------------------------------- /LIB/SLIDERI.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// SLIDERI ////////////// 3 | ; //////////////////////////////// 4 | 5 | ; Transició a la dreta 6 | ; Conte HALTS !. 7 | 8 | ; A = Char de ompliment 9 | ; DE = Pos. del Buffer Inicial 10 | ; B = Ample 11 | ; C = Alçada 12 | ; HL = Posicio Buffer pantalla 13 | 14 | ; Cal RAM : res 15 | ; Toca : HL,BC,DE 16 | ; Retorna : res 17 | ; Usa fun.: res 18 | 19 | SLIDERI: 20 | add HL,DE ; Inicia VBUFF 21 | 22 | ; Ample ja ho tinc a B 23 | ld DE,32 24 | 25 | .LOOPY: 26 | push BC 27 | push HL 28 | 29 | push AF 30 | m_VBUFF_READY 31 | pop AF 32 | 33 | halt 34 | 35 | ; Alçada ja la tinc a C 36 | ld B,C 37 | .LOOPX: 38 | ld (HL),A 39 | add HL,DE 40 | djnz .LOOPX 41 | pop HL 42 | pop BC 43 | inc HL 44 | djnz .LOOPY 45 | 46 | ; Ultima pintada 47 | m_VBUFF_READY 48 | halt 49 | 50 | ret 51 | -------------------------------------------------------------------------------- /LIB/SLOT3ROM.GEN: -------------------------------------------------------------------------------- 1 | ; Rutinas by Imanok 2 | ; Requiere RAM 3 | ; slotram 4 | ; slotvar 5 | 6 | ; *** Ejemplo llamada *** 7 | ;call search_slotram ; SOLO HACERLO UNA VEZ, al principio de programa 8 | ;ld hl,GAME_PAT 9 | ;ld de,buffer_datos_slot3 10 | ;ld bc,1200 11 | ;call SLOT3COPY2RAM 12 | ; OJO QUE DEJA LAS INTERRUPCIONES DESACTIVADAS 13 | 14 | ;---------------------------------------- 15 | ; SETSLOTPAGE3 16 | ; Posiciona el slot pasado 17 | ; en pagina 3 del Z80 18 | ; A: Formato FxxxSSPP 19 | ;---------------------------------------- 20 | 21 | ; --------------------- 22 | ; SEARCH_SLOTRAM 23 | ; Busca el slot de la ram 24 | ; Y almacena 25 | ; ---------------------- 26 | 27 | search_slotram: 28 | call RSLREG 29 | rlca 30 | rlca 31 | and 3 32 | ld C,A 33 | ld B,0 34 | ld HL,0FCC1h 35 | add HL,BC 36 | ld A,(HL) 37 | and 080h 38 | jr z,search_slotram0 39 | or C 40 | ld C,A 41 | inc HL 42 | inc HL 43 | inc HL 44 | inc HL 45 | ld A,(HL) 46 | rlca 47 | rlca 48 | rlca 49 | rlca 50 | and 0Ch 51 | search_slotram0: 52 | or C 53 | ld (slotram),A 54 | ret 55 | 56 | SETSLOTPAGE3: 57 | pop HL ; Return with jp [hl] 58 | SETSLOTPAGE3_nomem: 59 | ld B,A ; B = Slot param in FxxxSSPP format 60 | in A,(0A8h) 61 | and 000111111b 62 | ld D,A ; D = primary slot value 63 | ld A,B 64 | and 3 65 | rrca 66 | rrca 67 | or D 68 | ld D,A ; D = final value primary slot 69 | out (0A8h),A 70 | ld A,B 71 | bit 7,A 72 | jr z,SETSLOTPAGE3_exit 73 | ld A,B 74 | and 00001100b 75 | rrca 76 | rrca 77 | rrca 78 | rrca 79 | and 011000000b 80 | ld B,A 81 | ld a,(0FFFFh) 82 | cpl 83 | and 000111111b 84 | or B 85 | ld (0FFFFh),A ; Expanded slot selected 86 | SETSLOTPAGE3_exit: 87 | jp (HL) 88 | SETSLOTPAGE3_end: 89 | 90 | 91 | 92 | ; -------------------- 93 | ; SLOT3COPY2RAM 94 | ; TRANSFERENCIA_SLOT3 95 | ; HL: Apunta a origen de datos [en slot rom] 96 | ; DE: Apunta a destino [en slot ram] 97 | ; BC: Numero de bytes a transferir 98 | ; --------------------- 99 | SLOT3COPY2RAM: 100 | exx ; Activamos registros alternativos 101 | 102 | ld A,(slotram) 103 | ld E,A ; Guardamos el slot ram, ya que luego 104 | ; no tendremos memoria para consultarlo 105 | 106 | ; *** Habilitamos slot rom *** 107 | di ; Muy importante deshabilitar interrupciones, 108 | ; ya que acceden a ram 109 | ld A,(slotvar) 110 | call SETSLOTPAGE3 111 | 112 | ; *** Leemos byte *** 113 | exx ; Activamos registros normales 114 | ld A,(HL) ; Leemos byte de origen 115 | exx ; Activamos registros alternativos 116 | 117 | ld C,A ; Guardo el byte leido 118 | 119 | ; *** Habilitamos slot ram *** 120 | ld HL,SLOT3COPY2RAM_ret ; Direccion de retorno de la 121 | ; rutina SETSLTP3_NOMEM 122 | ld A,E ; Recupero el slot ram 123 | jp SETSLOTPAGE3_nomem 124 | 125 | SLOT3COPY2RAM_ret: 126 | ; *** Escribimos byte *** 127 | ld A,C ; Recupero el byte leido 128 | exx ; Activamos registros normales 129 | ld (DE),A ; Escribimos byte en destino 130 | 131 | ; *** Actualizamos punteros *** 132 | inc HL ; Incrementamos puntero origen 133 | inc DE ; Incrementamos puntero destino 134 | 135 | ; *** Actualizamos datos restantes *** 136 | dec BC 137 | ld A,B 138 | or C 139 | jr nz,SLOT3COPY2RAM 140 | ret 141 | -------------------------------------------------------------------------------- /LIB/SOUND.GEN: -------------------------------------------------------------------------------- 1 | ; ////////////////////////////// 2 | ; ///////// SOUND ////////////// 3 | ; ////////////////////////////// 4 | 5 | ; Posa una dada al PSG, tenint en compte el R7 especial 6 | 7 | ; A = Registre del PSG 8 | ; B = Valor a pujar 9 | 10 | ; Cal RAM : res 11 | ; Toca : B 12 | ; Retorna : res 13 | ; Usa fun.: res 14 | 15 | 16 | SOUND: 17 | cp 7 18 | jp z, .SPECIAL7 19 | 20 | out (0A0h),A 21 | ld A,B 22 | out (0A1h),A ; Puju a regsitre 23 | jp .END 24 | .SPECIAL7: 25 | out (0A0h),A 26 | in A,(0A2h) ; Lectura del R7 27 | and 11000000b ; Mascara per agafar dos bits de joys 28 | or B ; Afegeix Byte de B 29 | ld B,A 30 | ld A,7 ; Actualitza R7 del PSG 31 | out (0A0h),A 32 | ld A,B 33 | out (0A1h),A 34 | .END: 35 | ret 36 | -------------------------------------------------------------------------------- /LIB/SPRITES.GEN: -------------------------------------------------------------------------------- 1 | ; Contiene dues rutinas 2 | ; SPRT_INI : Inicialitza la taula RAM de SPRITES 3 | ; PUTSPRT : PUT SPRiTe com el de Basic a RAM SPRRAM 4 | 5 | 6 | ; //////////////////////////////// 7 | ; //////// SPRT_INI ////////////// 8 | ; //////////////////////////////// 9 | 10 | ; Inicialitza la taula RAM de SPRITES 11 | ; [X,Y]->[255,0] Color 0 y pattern A 12 | 13 | ; A = Num.Sprite 14 | ; IX= Direccio Taula RAM de SPRITES 15 | 16 | ; Cal RAM : res 17 | ; Toca : BC,DE,IX 18 | ; Retorna : res 19 | 20 | SPRT_INI: 21 | ; Inicialitzo la taula RAM de SPRITES 22 | sla A 23 | sla A 24 | ld DE,4 25 | ld B,32 26 | .LOOP1: 27 | ld (IX),191 ;Y =208 Especial Apagar 28 | ld (IX+1),255 ;X 29 | ld (IX+2),A ;Pattern 30 | ld (IX+3),0 ;Color 31 | add IX,DE 32 | djnz .LOOP1 33 | 34 | ret 35 | 36 | 37 | ; //////////////////////////////// 38 | ; ///////// PUTSPRT ////////////// 39 | ; //////////////////////////////// 40 | 41 | ; PUT SPRiTe com el de Basic 42 | 43 | ; H = Coordenada Y 44 | ; L = Coordenada X 45 | ; D = Patt.Num [*4 si es 16x16] 46 | ; E = Color 47 | ; C = Plano de Sprite [0 - 32] 48 | 49 | ; Cal RAM : SPRRAM [128bytes] 50 | ; Toca : HL 51 | ; Retorna : res 52 | ; Usa fun.: res 53 | 54 | PUTSPRT: 55 | push DE 56 | push HL 57 | 58 | ld A,C 59 | ld HL,SPRRAM 60 | sla A 61 | sla A 62 | ld D,0 63 | ld E,A 64 | add HL,DE 65 | 66 | pop DE ;Recupero [Y,X]HL a DE 67 | ld (HL),D 68 | inc HL 69 | ld (HL),E 70 | inc HL 71 | 72 | pop DE ;Recupero [Patt,Color]DE 73 | ld (HL),D 74 | inc HL 75 | ld (HL),E 76 | 77 | ret 78 | -------------------------------------------------------------------------------- /LIB/SPRITES2.GEN: -------------------------------------------------------------------------------- 1 | ; Contiene 2 | ; SPRT_INI : Inicialitza la taula RAM de SPRITES 3 | ; SPRT_COLOR_INI: Inicialitza la taula RAM de colors 4 | ; dels SPRITES amb el color triat en A 5 | ; PUTSPRT : PUT SPRiTe com el de Basic a RAM SPRRAM 6 | 7 | 8 | ; //////////////////////////////// 9 | ; //////// SPRT_INI ////////////// 10 | ; //////////////////////////////// 11 | 12 | ; Inicialitza la taula RAM de SPRITES 13 | ; [X,Y]->[255,0] Color 0 y pattern A 14 | 15 | ; A = Num.Sprite 16 | ; IX= Direccio Taula RAM de SPRITES 17 | 18 | ; Cal RAM : res 19 | ; Toca : BC,DE,IX 20 | ; Retorna : res 21 | 22 | SPRT_INI: 23 | ; Inicialitzo la taula RAM de SPRITES 24 | sla A 25 | sla A 26 | ld DE,4 27 | ld B,32 28 | .LOOP1: 29 | ld (IX),191 ;Y =208 Especial Apagar 30 | ld (IX+1),255 ;X 31 | ld (IX+2),A ;Pattern 32 | ;ld (IX+3),0 ;Color [Sin uso en MSX2] 33 | add IX,DE 34 | djnz .LOOP1 35 | 36 | ret 37 | 38 | ; ////////////////////////////////////// 39 | ; //////// SPRT_COLOR_INI ////////////// 40 | ; ////////////////////////////////////// 41 | ; Inicialitza la taula RAM de colors dels SPRITES 42 | ; amb el color triat en A 43 | 44 | ; A = Color Iniciador 45 | ; HL = Direccio Taula RAM de colors dels SPRITES 46 | 47 | ; Cal RAM : res 48 | ; Toca : BC,DE,HL 49 | ; Retorna : res 50 | 51 | SPRT_COLOR_INI: 52 | ld BC,512-1 53 | push HL 54 | pop DE 55 | inc DE 56 | ld (HL),A 57 | ldir 58 | ret 59 | 60 | ; //////////////////////////////// 61 | ; ///////// PUTSPRT ////////////// 62 | ; //////////////////////////////// 63 | 64 | ; PUT SPRiTe com el de Basic 65 | 66 | ; H = Coordenada Y 67 | ; L = Coordenada X 68 | ; D = Patt.Num [*4 si es 16x16] 69 | ; E = numero de block de dades de color del sprite 70 | ; C = Plano de Sprite [0 - 32] 71 | 72 | ; Cal RAM : SPRRAM [128bytes] 73 | ; Toca : DE,HL 74 | ; Retorna : res 75 | ; Usa fun.: res 76 | 77 | PUTSPRT: 78 | push DE 79 | push HL 80 | 81 | ld A,C 82 | ld HL,SPRRAM 83 | sla A 84 | sla A 85 | ld D,0 86 | ld E,A 87 | add HL,DE 88 | 89 | pop DE ;Recupero [Y,X]HL a DE 90 | ld (HL),D 91 | inc HL 92 | ld (HL),E 93 | inc HL 94 | 95 | pop DE ;Recupero [Patt,DE 96 | ; Verifica si hi ha un canvi de Patt, 97 | ; en el cas que sí, toquem el SPRCOLRAM 98 | ld A,(HL) 99 | cp D 100 | ret z 101 | ld (HL),D 102 | 103 | ; Guardo el color del sprite 104 | ld HL,SPRCOLRAM 105 | ld D,0 106 | push DE ; Guardo block de color per agafar de RAM 107 | ld E,C 108 | ; Multiplico per 16 [4 veces] 109 | sla E 110 | rl D 111 | sla E 112 | rl D 113 | sla E 114 | rl D 115 | sla E 116 | rl D 117 | add HL,DE ; Direccio RAM on va a parar la info de color 118 | pop DE ; Recupero block de color 119 | push HL 120 | ld HL,COLOR_DATA 121 | ; Multiplico per 16 [4 veces] 122 | sla E 123 | rl D 124 | sla E 125 | rl D 126 | sla E 127 | rl D 128 | sla E 129 | rl D 130 | add HL,DE ; Direccio RAM on hi ha el color del sprite 131 | pop DE ; Recupero destinacio del color 132 | push BC 133 | ld BC,16 134 | ldir 135 | pop BC 136 | ret 137 | -------------------------------------------------------------------------------- /LIB/SPRT16HFLIP.GEN: -------------------------------------------------------------------------------- 1 | ; ///////////////////////////////////// 2 | ; ///////// SPRT16HFLIP /////////////// 3 | ; ///////////////////////////////////// 4 | 5 | ; Gira un sprite de 16 bits en Horizontal en modo espejo 6 | 7 | ; IX= Dir. Sprite Original 8 | ; IY= Dir. Sprite modo espejo 9 | 10 | ; Cal ROM : res 11 | ; Toca : B,C,Incrementa IX y IY 12 | ; Retorna : IY = bytes modo espejo 13 | ; Usa fun.: REVERSE_A 14 | 15 | SPRT16HFLIP: 16 | ld B,16 ; Realizamos espejo de 16 primeros bytes 17 | push IY 18 | .LOOP: 19 | ld A,(IX) 20 | call REVERSE_A 21 | ld (IY+16),A 22 | inc IX 23 | inc IY 24 | djnz .LOOP 25 | ld B,16 ; Realizamos espejo de 16 segundos bytes 26 | pop IY 27 | .LOOP2: 28 | ld A,(IX) 29 | call REVERSE_A 30 | ld (IY),A 31 | inc IX 32 | inc IY 33 | djnz .LOOP2 34 | ld BC,16 ; Al salir deja a IY apuntando al 35 | add IY,BC ; siguiente supuesto sprite 36 | 37 | ret 38 | 39 | ; /////////////////////////////////// 40 | ; ///////// REVERSE_A /////////////// 41 | ; /////////////////////////////////// 42 | ;- Gira byte en A 43 | ; 17 bytes y 66 ciclos de reloj 44 | ; autor: calcmaniac84 45 | 46 | ; A = byte a girar 47 | 48 | ; Cal ROM : res 49 | ; Toca : C 50 | ; Retorna : A = byte espejo 51 | ; Usa fun.: res 52 | 53 | REVERSE_A: 54 | ld C,A ;C=ABCDEFGH 55 | rrca ;A=HABCDEFG 56 | rrca ;A=GHABCDEF 57 | xor C 58 | and 10101010b 59 | xor C ;A=GBADCFEH 60 | ld C,A ;C=GBADCFEH 61 | rrca ;A=HGBADCFE 62 | rrca ;A=EHGBADCF 63 | rrca ;A=FEHGBADC 64 | rrca ;A=CFEHGBAD 65 | xor C 66 | and 01100110b 67 | xor C ;A=GFEDCBAH 68 | rrca ;A=HGFEDCBA 69 | ret -------------------------------------------------------------------------------- /LIB/SPRT2COL.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// SPRT2COL ///////////// 3 | ; //////////////////////////////// 4 | 5 | ; 2 Sprites Colision ? 6 | 7 | ; Las coordenadas de los Sprites deben estar definidos en RAM 8 | ; 3 bytes con el siguiente orden Y,X,ON/Off 9 | ; Se supone que el sprite viene colocado en X,Y por 10 | ; esquina superior izquierda. 11 | 12 | ; IX = Inicio de Array RAM de Sprite 1 13 | ; IY = Inicio de Array RAM de Sprite 2 14 | ; D = Size X de Sprite 1 [INCXSprt1] 15 | ; E = Size Y de Sprite 1 [INCYSprt1] 16 | ; B = Size X de Sprite 2 [INCXSprt2] 17 | ; C = Size Y de Sprite 2 [INCYSprt2] 18 | 19 | ; Parejas DE, BC los valores serian 20 | ; 8x8 ld RR,0808h 21 | ; 16x16 ld RR,1010h 22 | ; 32x32 ld RR,2020h 23 | 24 | ; Retornar 1 o 0 si entre les coordenades dels sprites es toquen 25 | 26 | ; Cal RAM : res 27 | ; Toca : B,C,D,E,IX,IY 28 | ; Retorna : A = 1 si es toquen, 0 si no es toquen 29 | ; Usa fun.: res 30 | 31 | SPRT2COL: 32 | ld A,(IX+2) ; Esta actiu el sprite 1 ? 33 | cp 1 34 | jr nz,.ENDNO 35 | ld A,(IY+2) ; Esta actiu el sprite 2 ? 36 | cp 1 37 | jr nz,.ENDNO 38 | 39 | ld A,(IY+0) ; Y_Sprt1 < [ Y_Sprt2+INCYSprt2] 40 | add A,C 41 | jr nc,.CONT 42 | ld A,0FFh 43 | .CONT: 44 | ld C,A 45 | ld A,(IX+0) 46 | cp C 47 | jr nc,.ENDNO 48 | 49 | ;ld A,(IX+0) (Anulable pq ya esta el valor ahi) 50 | ; Y_Sprt2 < [ Y_Sprt1+INCYSprt1] 51 | add A,E 52 | jr nc,.CONT2 53 | ld A,0FFh 54 | .CONT2: 55 | ld E,A 56 | ld A,(IY+0) 57 | cp E 58 | jr nc,.ENDNO 59 | 60 | ld A,(IY+1) ; X_Sprt1 < [ X_Sprt2+INCXSprt2] 61 | add A,B 62 | jr nc,.CONT3 63 | ld A,0FFh 64 | .CONT3: 65 | ld B,A 66 | ld A,(IX+1) 67 | cp B 68 | jr nc,.ENDNO 69 | 70 | ;ld A,(IX+1) (Anulable pq ya esta el valor ahi) 71 | ; X_Sprt2 < [ X_Sprt1+INCXSprt1] 72 | add A,D 73 | jr nc,.CONT4 74 | ld A,0FFh 75 | .CONT4: 76 | ld D,A 77 | ld A,(IY+1) 78 | cp D 79 | jr nc,.ENDNO 80 | .ENDSI: 81 | ld A,1 82 | ret 83 | .ENDNO: 84 | xor A 85 | ret 86 | -------------------------------------------------------------------------------- /LIB/SPRTLD.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// SPRTLD /////////////// 3 | ; //////////////////////////////// 4 | 5 | ; SPRiTes pattern LoaD 6 | 7 | ; B = Sprites a pujar de 8x8 8 | ; HL= Punter dels patrons del Sprites 9 | 10 | ; Cal ROM : res 11 | ; Toca : B,HL,DE 12 | ; Retorna : res 13 | ; Usa fun.: IWBVRM 14 | 15 | SPRTLD: 16 | ld DE,VRM_SPP 17 | CALL IWBVRM 18 | 19 | ret 20 | -------------------------------------------------------------------------------- /LIB/SPRTLDPOS.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; ///////// SPRTLDPOS //////////// 3 | ; //////////////////////////////// 4 | 5 | ; SPRiTes pattern LoaD to POSition 6 | 7 | ; B = Sprites a pujar de 8x8 8 | ; L = Num Patro inicial a fer el load a VRAM 9 | ; DE = Punter dels patrons del Sprites 10 | 11 | ; Cal ROM : res 12 | ; Toca : B,HL,DE 13 | ; Retorna : res 14 | ; Usa fun.: IWBVRM 15 | 16 | SPRTLDPOS: 17 | push DE 18 | ; L * 32 19 | ld H,0 ; *32 con acarreo (5 veces) 20 | add hl,hl ; la distancia al sprite 21 | add hl,hl ; que toca. 22 | add hl,hl 23 | add hl,hl 24 | add hl,hl 25 | ld DE,VRM_SPP 26 | add HL,DE 27 | push HL 28 | pop DE ; En DE direccio VRAM 29 | pop HL ; En HL direccio RAM 30 | CALL IWBVRM 31 | 32 | ret 33 | -------------------------------------------------------------------------------- /LIB/TECLA.GEN: -------------------------------------------------------------------------------- 1 | ; //////////////////////////////// 2 | ; //////////// TECLA ///////////// 3 | ; //////////////////////////////// 4 | 5 | ; Rutina de control del TECLAT 6 | ; volca l'estat del TECLAT [10bytes] al offset 'KEYBOARD' 7 | ; es crida la rutina cada cop que interesa mirar el TECLAT 8 | ; ideal per colocar a la rutina de interrupcio 9 | 10 | ; utilitza els ports de TECLAt directament 11 | ; en la posicio 0AAh... 12 | ; els 4 bits baixos [xxxx3210] indiquen posicio que llegeix 13 | ; els 4 bits alts [7654xxxx] son altres coses, millor no modificar 14 | ; en la posicio 0A9h hi ha el valor de la posicio seleccionada 15 | 16 | ; Cal RAM : KEYBOARD, KEY_f 17 | ; Toca : A,B,C,HL 18 | ; Retorna : KEYBOARD [actualitzat] 19 | ; Usa fun.: res 20 | 21 | TECLA: ld a,0FFh 22 | ld (KEY_f),a 23 | ld hl,KEYBOARD 24 | ld b,10 ;repeteix bucle 10 cops,la matriu ocupa 10bytes 25 | TECLA0: push bc 26 | in a,(0AAh) ;agafem el valor de [AA] i posem a 0 la posicio 27 | and 11110000b ;de TECLAt a llegir sente tocar els altres bits 28 | dec b ;posem la posicio a llegir [b-1] de 9 a 0 29 | add a,b 30 | out (0AAh),a ;enviem la posicio a llegir 31 | in a,(0A9h) ;llegim l'estat 32 | ld (hl),a ;volquem la info a TECLAt 33 | inc hl ;apuntem al byte seguent de TECLAt 34 | pop bc 35 | djnz TECLA0 ;repetim bucle 36 | 37 | ret 38 | -------------------------------------------------------------------------------- /LIB/TIMERS.GEN: -------------------------------------------------------------------------------- 1 | ; Rutines per Timers 2 | ; 3 | ; 4 | 5 | 6 | ; ////////////////////////////////// 7 | ; ///////// TIMERINI /////////////// 8 | ; ////////////////////////////////// 9 | ; Inicia els timers a zero 10 | ; Cal RAM : TIMER, TIMEREND 11 | ; Toca : HL 12 | ; Retorna : res 13 | ; Usa fun.: 14 | TIMERINI: 15 | ld HL,TIMER 16 | ld B,TIMEREND-TIMER 17 | xor A 18 | .LOOP: 19 | ld (HL),A 20 | inc HL 21 | djnz .LOOP 22 | 23 | ret 24 | 25 | 26 | ; ////////////////////////////////// 27 | ; ///////// TIMERUPDATE //////////// 28 | ; ////////////////////////////////// 29 | ; Actualitza els Timers fent la resta de 1 30 | ; Cal RAM : TIMER, TIMEREND 31 | ; Toca : HL 32 | ; Retorna : res 33 | ; Usa fun.: 34 | TIMERUPDATE: 35 | ld HL,TIMER 36 | ld B,TIMEREND-TIMER 37 | .LOOP: 38 | ld A,(HL) 39 | or A 40 | jr z,.END 41 | dec A 42 | ld (HL),A 43 | .END: 44 | inc HL 45 | djnz .LOOP 46 | 47 | ret 48 | 49 | 50 | ; ////////////////////////////////// 51 | ; ///////// TIMERSET ///////////// 52 | ; ////////////////////////////////// 53 | ; Carrega un valor al timer triat 54 | ; Cal RAM : TIMER, TIMEREND 55 | ; Toca : HL,DE 56 | ; Param : B = Num Timer 57 | ; C = Valor a carregar al timer 58 | ; Retorna : res 59 | ; Usa fun.: 60 | TIMERSET: 61 | push DE 62 | push HL 63 | ld E,B 64 | ld D,0 65 | ld HL,TIMER 66 | add HL,DE ; Preparo punter per setejar el timer 67 | ld (HL),C 68 | pop HL 69 | pop DE 70 | 71 | ret 72 | 73 | 74 | ; ////////////////////////////////// 75 | ; ///////// TIMERCHECK ///////////// 76 | ; ////////////////////////////////// 77 | ; Ens diu si el timer esta a zero ja o no. 78 | ; Cal RAM : TIMER, TIMEREND 79 | ; Toca : HL,BC 80 | ; Param : A = Num Timer 81 | ; Retorna : Flag Z si el Timer esta a Zero. 82 | ; Usa fun.: 83 | TIMERCHECK: 84 | push HL 85 | push BC 86 | ld C,A 87 | ld B,0 88 | ld HL,TIMER 89 | add HL,BC ; Preparo punter per verificar timer 90 | ld A,(HL) 91 | or A ; Seteja el Flag Z 92 | pop BC 93 | pop HL 94 | 95 | ret 96 | -------------------------------------------------------------------------------- /LIB/TTREPLAYDAT.GEN: -------------------------------------------------------------------------------- 1 | 2 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 3 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 4 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 5 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 6 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 7 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 8 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 9 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 10 | _VOLUME_TABLE: 11 | INCBIN "LIB/TTvoltable_combined.bin" 12 | 13 | ;Konami values found in Nemesis 2 replayer. 14 | C_PER equ $6a*32 15 | C1_PER equ $64*32 16 | D_PER equ $5e*32 17 | D1_PER equ $59*32 18 | E_PER equ $54*32 19 | F_PER equ $4f*32 20 | F1_PER equ $4a*32 21 | G_PER equ $46*32 22 | G1_PER equ $42*32 23 | A_PER equ $3f*32 24 | A1_PER equ $3b*32 25 | B_PER equ $38*32 26 | 27 | TRACK_ToneTable: 28 | dw C_PER/1 ,C1_PER/1 ,D_PER/1 ,D1_PER/1 ,E_PER/1 ,F_PER/1 ,F1_PER/1 ,G_PER/1 ,G1_PER/1 ,A_PER/1 ,A1_PER/1 ,B_PER/1 29 | dw C_PER/2 ,C1_PER/2 ,D_PER/2 ,D1_PER/2 ,E_PER/2 ,F_PER/2 ,F1_PER/2 ,G_PER/2 ,G1_PER/2 ,A_PER/2 ,A1_PER/2 ,B_PER/2 30 | dw C_PER/4 ,C1_PER/4 ,D_PER/4 ,D1_PER/4 ,E_PER/4 ,F_PER/4 ,F1_PER/4 ,G_PER/4 ,G1_PER/4 ,A_PER/4 ,A1_PER/4 ,B_PER/4 31 | dw C_PER/8 ,C1_PER/8 ,D_PER/8 ,D1_PER/8 ,E_PER/8 ,F_PER/8 ,F1_PER/8 ,G_PER/8 ,G1_PER/8 ,A_PER/8 ,A1_PER/8 ,B_PER/8 32 | dw C_PER/16 ,C1_PER/16 ,D_PER/16 ,D1_PER/16 ,E_PER/16 ,F_PER/16 ,F1_PER/16 ,G_PER/16 ,G1_PER/16 ,A_PER/16 ,A1_PER/16 ,B_PER/16 33 | dw C_PER/32 ,C1_PER/32 ,D_PER/32 ,D1_PER/32 ,E_PER/32 ,F_PER/32 ,F1_PER/32 ,G_PER/32 ,G1_PER/32 ,A_PER/32 ,A1_PER/32 ,B_PER/32 34 | dw C_PER/64 ,C1_PER/64 ,D_PER/64 ,D1_PER/64 ,E_PER/64 ,F_PER/64 ,F1_PER/64 ,G_PER/64 ,G1_PER/64 ,A_PER/64 ,A1_PER/64 ,B_PER/64 35 | dw C_PER/128,C1_PER/128,D_PER/128,D1_PER/128,E_PER/128,F_PER/128,F1_PER/128,G_PER/128,G1_PER/128,A_PER/128,A1_PER/128,B_PER/128 36 | 37 | 38 | TRACK_Vibrato_sine: 39 | db 0*2, 2*2, 4*2, 7*2,11*2,16*2,22*2,28*2,35*2,43*2,51*2,59*2,68*2,77*2,87*2,96*2 40 | db 96*2,86*2,77*2,68*2,59*2,51*2,43*2,35*2,28*2,22*2,16*2,11*2, 7*2, 4*2, 2*2, 0*2 41 | 42 | TRACK_Vibrato_triangle: 43 | db 0, 6,12,18,24,30,36,42,48,54,60,66,72,78,84,90 44 | db 96,90,84,78,72,66,60,54,48,42,36,30,24,18,12, 6 45 | 46 | TRACK_Vibrato_pulse: 47 | db 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 48 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 49 | -------------------------------------------------------------------------------- /LIB/TTSCCDETECT.GEN: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------ 2 | ; SCC-search v1.0 3 | ; by Alwin Henseler 4 | ; using method described in bulletin # 18 MSX-club Enschede 5 | ; input: none 6 | ; output: B=slot that contains SCC (=255 if no SCC found) 7 | 8 | enaslt equ 0024h 9 | exptbl equ 0fcc1h 10 | slttbl equ 0fcc5h 11 | 12 | scc_type_check: db 0 13 | 14 | SCC_FIND: 15 | ;di 16 | in a,(#a8) ; read prim. slotregister 17 | rra 18 | rra 19 | rra 20 | rra 21 | and 00000011b ; A = prim.slot page 2 22 | ld b,0 23 | ld c,a 24 | ld hl,exptbl 25 | add hl,bc 26 | bit 7,(hl) ; page 2-slot expanded ? 27 | jr z,scctest 28 | ld hl,slttbl 29 | add hl,bc 30 | ld a,(hl) ; A = sec.sel.reg. of page 2-slot 31 | rra 32 | rra 33 | and 00001100b ; bit 1/2 = sec.slot page 2 34 | or c 35 | set 7,a ; compose sec.slot-code 36 | scctest: push af ; save page 2-slot on the stack 37 | ld a,(exptbl) ; 1st slot to test 38 | 39 | testslot: push af ; save test-slot on the stack 40 | ld h,#80 41 | call enaslt ; switch slot-to-test in 8000-bfffh 42 | 43 | ld a,(scc_type_check) ; 0 = scc, 1=scc+/scc-I 44 | and a 45 | jr z,scc_test 46 | 47 | scci_test: 48 | ld hl,#b000 49 | ld b,(hl) ; save contents of address 9000h 50 | ld (hl),#3f ; activate SCC (if present) 51 | ld h,#9c ; address of SCC-register mirrors 52 | ld de,#b800 ; 9800h = address of SCC-registers 53 | testregi: ld a,(de) 54 | ld c,a ; save contents of address 98xxh 55 | ld a,(hl) ; read byte from address 9cxxh 56 | cpl ; and invert it 57 | ld (de),a ; write inverted byte to 98xxh 58 | cp (hl) ; same value on 9cxxh ? 59 | ld a,c 60 | ld (de),a ; restore value on 98xxh 61 | jr nz,nextslot ; unequal -> no SCC -> continue search 62 | inc hl 63 | inc de ; next test-addresses 64 | bit 7,l ; 128 adresses (registers) tested ? 65 | jr z,testregi ; no -> repeat mirror-test 66 | ld a,b 67 | ld (#b000),a ; restore value on 9000h 68 | xor a 69 | ld ($bfff),a ; Set SCC+ in SCC mode 70 | pop bc ; retrieve slotcode (=SCC-slot) from stack 71 | jr done ; SCC found, restore page 2-slot & return 72 | 73 | scc_test: 74 | ld hl,#9000 75 | ld b,(hl) ; save contents of address 9000h 76 | ld (hl),#3f ; activate SCC (if present) 77 | ld h,#9c ; address of SCC-register mirrors 78 | ld de,#9800 ; 9800h = address of SCC-registers 79 | testreg: ld a,(de) 80 | ld c,a ; save contents of address 98xxh 81 | ld a,(hl) ; read byte from address 9cxxh 82 | cpl ; and invert it 83 | ld (de),a ; write inverted byte to 98xxh 84 | cp (hl) ; same value on 9cxxh ? 85 | ld a,c 86 | ld (de),a ; restore value on 98xxh 87 | jr nz,nextslot ; unequal -> no SCC -> continue search 88 | inc hl 89 | inc de ; next test-addresses 90 | bit 7,l ; 128 adresses (registers) tested ? 91 | jr z,testreg ; no -> repeat mirror-test 92 | ld a,b 93 | ld (#9000),a ; restore value on 9000h 94 | pop bc ; retrieve slotcode (=SCC-slot) from stack 95 | jr done ; SCC found, restore page 2-slot & return 96 | 97 | 98 | 99 | 100 | nextslot: ld a,b 101 | ld (#b000),a ; restore value on 9000h 102 | pop bc ; retrieve slotcode from stack 103 | bit 7,b ; test-slot = sec.slot ? 104 | jr z,nextprim 105 | ld a,b 106 | add a,4 ; increase sec.slotnumber 107 | bit 4,a ; sec.slot = 4 ? 108 | jr z,testslot 109 | nextprim: ld a,b 110 | and 00000011b 111 | cp 3 ; prim.slot = 3 ? 112 | jr z,noscc 113 | inc a ; increase prim.slotnumber 114 | ld d,0 115 | ld e,a 116 | ld hl,exptbl 117 | add hl,de 118 | or (hl) ; combine slot-expansion with slotcode 119 | jr testslot 120 | 121 | noscc: ld b,255 ; code for no SCC 122 | done: pop af ; retrieve page 2-slot from stack 123 | push bc 124 | ld h,#80 125 | ld (mapper_slot),a 126 | call enaslt ; restore original page 2-slot 127 | pop bc 128 | 129 | ;--- store the found slot. 130 | ld a,b 131 | ld (SCC_slot),a 132 | ;ei 133 | ret 134 | -------------------------------------------------------------------------------- /LIB/TTvoltable_combined.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamque/TPMSX-Engine/cd8dbb57581bfcead055d3a7cccbdd6fe19a99dd/LIB/TTvoltable_combined.bin -------------------------------------------------------------------------------- /LIB/VNOTAS.GEN: -------------------------------------------------------------------------------- 1 | 2 | VNOTAS: 3 | ; Octava 0 [0] 4 | db 05Dh,0Dh,09Ch,0Ch,0E7h,0Bh,03Ch,0Bh,09Bh,0Ah,002h,0Ah,073h,9h,0EBh,8h,6Bh,8h,0F2h,7h,080h,7h,014h,7h 5 | ; Octava 1 [24] 6 | db 0AEh,06h,04Eh,06h,0F4h,05h,09Eh,05h,04Dh,05h,001h,05h,0B9h,4h,075h,4h,35h,4h,0F9h,3h,0C0h,3h,08Ah,3h 7 | ; Octava 2 [48] 8 | db 057h,03h,027h,03h,0FAh,02h,0CFh,02h,0AFh,02h,081h,02h,05Dh,2h,03Bh,2h,1Bh,2h,0FCh,1h,0E0h,1h,0C5h,1h 9 | ; Octava 3 [72] 10 | db 0ACh,01h,094h,01h,07Dh,01h,068h,01h,053h,01h,040h,01h,02Eh,1h,01Dh,1h,0Dh,1h,0FEh,0h,0F0h,0h,0E2h,0h 11 | ; Octava 4 [96] 12 | db 0D6h,00h,0CAh,00h,0BEh,00h,0B4h,00h,0AAh,00h,0A0h,00h,097h,0h,08Fh,0h,87h,0h,07Fh,0h,078h,0h,071h,0h 13 | ; Octava 5 [120] 14 | db 06Bh,00h,065h,00h,05Fh,00h,05Ah,00h,055h,00h,050h,00h,04Ch,0h,047h,0h,43h,0h,040h,0h,03Bh,0h,039h,0h 15 | ; Octava 6 [144] 16 | db 035h,00h,032h,00h,030h,00h,02Dh,00h,02Ah,00h,028h,00h,026h,0h,024h,0h,22h,0h,020h,0h,01Eh,0h,01Ch,0h 17 | ; Octava 7 [168] 18 | db 01Bh,00h,019h,00h,018h,00h,016h,00h,015h,00h,014h,00h,013h,0h,012h,0h,11h,0h,010h,0h,00Fh,0h,00Eh,0h 19 | -------------------------------------------------------------------------------- /LIB/_EQUS_.GEN: -------------------------------------------------------------------------------- 1 | IF USE_SCREEN ==2 2 | ; Posicions de memoria de Screen 2 3 | VRM_PAT equ 0000h ; Tile Patterns 4 | VRM_COL equ 2000h ; Tile Colors 5 | VRM_MAP equ 1800h ; Tile Map (Screen) 6 | VRM_SPA equ 1B00h ; Sprite Attributes (Y,X,PatNum,Color) 7 | VRM_SPP equ 3800h ; Sprite Patterns 8 | ENDIF 9 | 10 | IF USE_SCREEN == 4 11 | ; Posicions de memoria de Screen 4 12 | ; Tiles igual que SCREEN 2 13 | VRM_PAT equ 0000h ; Tile Patterns 14 | VRM_COL equ 2000h ; Tile Colors 15 | VRM_MAP equ 1800h ; Tile Map (Screen) 16 | VRM_SPC equ 1C00h ; Sprite Colors 17 | VRM_SPA equ 1E00h ; Sprite Attributes (Y,X,PatNum,Color) 18 | VRM_PAL equ 1E80h ; Palette Colors 7680h-769Fh 19 | VRM_SPP equ 3800h ; Sprite Patterns 20 | ENDIF 21 | 22 | IF USE_SCREEN == 5 23 | ; Posicions de memoria de Screen 5 24 | VRM_BIT equ 0000h ; Bitmap (Screen) 0000h-69FFh 25 | ; Del 7000h a 73FFh ???? Son pixels del Bitmap 26 | ; no visibles si el Reg27d = 0 27 | VRM_SPC equ 7400h ; Sprite Colors 28 | VRM_SPA equ 7600h ; Sprite Attributes (Y,X,PatNum,Color) 29 | VRM_PAL equ 7680h ; Palette Colors 7680h-769Fh 30 | VRM_SPP equ 7800h ; Sprite Patterns 31 | ;VRM_SPP equ 1F800h ; Sprite Patterns 32 | 33 | ; 1F400h ; Sprite Colors Full Address 34 | ; 11111010000000000 -> 111 | 11 0100 | 0000 0000 35 | ;VRM_SPC_HIGH equ 07h ; Sprite Colors High (A16-A14) 36 | ;VRM_SPC_LOW_H equ 034h ; Sprite Colors Low_High (A13-A8) 37 | ;VRM_SPC_LOW_L equ 00h ; Sprite Colors Low_Low (A7-A0) 38 | 39 | ; 1F600h ; Sprite Attributes Full Address(Y,X,Pat,Color) 40 | ; 11111011000000000 -> 111 | 11 0110 | 0000 0000 41 | ;VRM_SPA_HIGH equ 07h ; Sprite Attributes High (A16-A14) 42 | ;VRM_SPA_LOW_H equ 036h ; Sprite Attributes Low_High (A13-A8) 43 | ;VRM_SPA_LOW_L equ 00h ; Sprite Attributes Low_Low (A7-A0) 44 | 45 | ; 1F800h ; Sprite Patterns Full Address 46 | ; 11111100000000000 -> 111 | 11 1000 | 0000 0000 47 | ;VRM_SPP_HIGH equ 07h ; Sprite Patterns High (A16-A14) 48 | ;VRM_SPP_LOW_H equ 038h ; Sprite Patterns Low_High (A13-A8) 49 | ;VRM_SPP_LOW_L equ 00h ; Sprite Patterns Low_Low (A7-A0) 50 | 51 | ENDIF 52 | 53 | ; HighSpeed VDP CMD MSX2: (Que conozco) 54 | CMDSTOP equ 000h ; Stop 55 | CMDCOPYV equ 0E0h ; Highspeed Copy Vertically, VRAM -> VRAM 56 | CMDCOPY equ 0D0h ; Copy Rectangle VRAM->VRAM 57 | CMDCOPY0 equ 098h ; Copy Rectangle VRAM->VRAM Mask color 0 58 | CMDRECT equ 080h ; Fill Rectangle [LineBF] 59 | CMDLINE equ 070h ; Line normal with color 60 | 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /RAM/CONTROL.RAM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------ 2 | ; Variables de Control (Joystick, Teclado y ratón) 3 | ;------------------------------------------------ 4 | JOY1: byte ; Valores del Joystick 1 5 | ; bits 5-0 (B/A/R/L/D/U) a 1 6 | CURSORS: byte ; Valores del CURSORS / SPACE / M o GRAPH 7 | ; bits 5-0 (B/A/R/L/D/U) a 1 8 | MOUSERELX: byte ; Incremento X de Mouse 9 | MOUSERELY: byte ; Incremento Y de Mouse 10 | MOUSEX: byte ; Posición X del Mouse 11 | MOUSEY: byte ; Posición Y del Mouse 12 | MOUSESPR: byte ; Número de Patrón Sprite para Mouse 13 | MOUSEON: byte ; Si 1 tenim Ratón en el port 1. 14 | 15 | PLY1CONTROL: byte ; Valores del Joystick 1 + CURSORS sumados con OR 16 | ; bits 5-0 (B/A/R/L/D/U) a 1 17 | 18 | ;--------------------- 19 | ; De fitxer: TECLA.GEN 20 | ;--------------------- 21 | KEYBOARD: ds 10 ; Buffer del polling de TECLA.GEN 22 | KEY_f: byte ; Variable de TECLA.GEN 23 | 24 | ;------------------- 25 | ; De fitxer: CIN.GEN 26 | ;------------------- 27 | TEXT_X: byte ; Posición X del input de teclado 28 | TEXT_Y: byte ; Posición Y del input de teclado 29 | TEXT_MAX: byte ; Longitud máxima de texto entrado 30 | TEXT_CHAR_OFF: byte ; Offset de la posición de tile de la A 31 | TEXT_IN: ds 32 ; Variable para guardar lo introducido por teclado 32 | TEXT_COUNT: byte ; Cuenta cuantas letras se han introducido 33 | TEXT_ALLIN: byte ; Se pone a 1 si se ha pulsado ENTER. El texto está completo 34 | 35 | ;------------------- 36 | ; De fitxer: MINIPSG.GEN 37 | ;------------------- 38 | PLAYRNDVALUE: byte ; Valor random a playear. 39 | PLAYRNDTIMES: byte ; Veces del RND player. 40 | PLAYAMBION: byte ; Semaforo que indica que hay un Ambiente sonando 41 | -------------------------------------------------------------------------------- /RAM/GAME.RAM: -------------------------------------------------------------------------------- 1 | ;-------------------- 2 | ; Variables del joc 3 | ;-------------------- 4 | -------------------------------------------------------------------------------- /RAM/PLY42RUT.RAM: -------------------------------------------------------------------------------- 1 | ;Variables de la Rutina de PLAYER v4.1 2 | ZMA_MAXVOICE equ 2 ; Max canals/veus 3 | ZMA_BUFFERSIZE equ 117 ; Mida en bytes de dades d'una canal 4 | 5 | ZMARAM: ds ZMA_BUFFERSIZE * ZMA_MAXVOICE 6 | ZMA_CURVOICE: byte ; ID del ZMARAM que ha de sonar 7 | -------------------------------------------------------------------------------- /RAM/PT3PLAYER.RAM: -------------------------------------------------------------------------------- 1 | ;--------------------- 2 | ; Variables de la Rutina PT3 Player 3 | ;--------------------- 4 | PT3_ON: byte ; Para el Timer 0 o 1 perque s'actualitzi la musica 5 | PT3_PATTERN_POS: byte ; Posicio Pattern que esta sonant 6 | PT3_NUMSONG: byte ; Contador de numero de canço 7 | PT3_SECOND: byte ; Segons del pattern actual 8 | PT3_FRAME: byte ; Numero de frame del segon actual 9 | 10 | PT3_SETUP: byte ; bit0 a 1, si vols que soni sense loop 11 | ; bit7 es posa a 1 cada cop que pasa per el punt de loop 12 | PT3_MODADDR: word 13 | PT3_CrPsPtr: word 14 | PT3_SAMPTRS: word 15 | PT3_OrnPtrs: word 16 | PT3_PDSP: word 17 | PT3_CSP: word 18 | PT3_PSP: word 19 | PT3_PrNote: byte 20 | PT3_PrSlide: word 21 | PT3_AdInPtA: word 22 | PT3_AdInPtB: word 23 | PT3_AdInPtC: word 24 | PT3_LPosPtr: word 25 | PT3_PatsPtr: word 26 | PT3_Delay: byte 27 | PT3_AddToEn: byte 28 | PT3_Env_Del: byte 29 | PT3_ESldAdd: word 30 | 31 | VARS: 32 | ChanA: ds 29 ;CHNPRM_Size 33 | ChanB: ds 29 ;CHNPRM_Size 34 | ChanC: ds 29 ;CHNPRM_Size 35 | 36 | ;--------------------- 37 | ; GlobalVars 38 | ;--------------------- 39 | DelyCnt: byte 40 | CurESld: word 41 | CurEDel: byte 42 | Ns_Base_AddToNs: 43 | Ns_Base: byte 44 | AddToNs: byte 45 | 46 | AYREGS: 47 | VT_: ds 14 48 | EnvBase: word 49 | VAR0END: ds 240 50 | -------------------------------------------------------------------------------- /RAM/SET48K.RAM: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------- 2 | ; Variable per guardar el slot on son les pagines 3 | ; i formar be en linea els 48ks 4 | ;---------------------------------------------------- 5 | slotvar: byte ; El meu slot ROM 6 | 7 | ;---------------------------------------------------- 8 | ; Variable per guardar el slot on estan les pagines RAM 9 | ; en cas de voler fer una 64ks 10 | ;---------------------------------------------------- 11 | ;slotram: byte ; El meu slot RAM 12 | -------------------------------------------------------------------------------- /RAM/TIMER.RAM: -------------------------------------------------------------------------------- 1 | ;------------------------ 2 | ; Del fitxer: TIMERS.GEN 3 | ;------------------------ 4 | ; Usos en otras rutinas: 5 | ; Timer 0: 6 | ; Timer 1: 7 | ; Timer 2: 8 | ; Timer 3: Es fa servir a MINIPSG para contar el temps del FX vs MUSIC 9 | ; Timer 4: Es fa servir a CIN.GEN para captura de teclat 10 | TIMER: ds 6 ; Timers decrementals (Max 255) 11 | TIMEREND: 12 | 13 | ;----------------------------------------------- 14 | ; Variables de la Rutina de TIMER en Interrupcio 15 | ;----------------------------------------------- 16 | TIMER_T: byte ; Valor que canvia a cada Interrupcio 17 | TIM_SPC: byte ; 1 si hi ha SPRITE COLISION 18 | TIM_RND: word ; llavor RANDOM 19 | -------------------------------------------------------------------------------- /RAM/TTREPLAY.RAM: -------------------------------------------------------------------------------- 1 | ;================================ 2 | ; The new replayer. 3 | ; 4 | ; Persistent RAM unswappable 5 | ; 6 | ;================================ 7 | 8 | TRACK_Instrument equ 0-17 9 | TRACK_Command equ 1-17 10 | TRACK_MacroPointer equ 2-17 11 | TRACK_MacroStart equ 4-17 12 | TRACK_MacroRestart equ 6-17 ; no longer needed 13 | TRACK_Note equ 7-17 14 | TRACK_Volume equ 8-17 15 | TRACK_Waveform equ 9-17 16 | TRACK_Flags equ 10-17 17 | ; 0 = note trigger 18 | ; 1 = note active 19 | ; 4 = morph active ;-< for SCC when 1 then waveform is following morph buffer 20 | ; 3 = command trigger 21 | ; 2 = envelope trigger 22 | ; 5 = instrument trigger 23 | ; 6 = waveform trigger 24 | ; 7 = PSG/SCC 25 | TRACK_empty equ 11-17 ; needed for pushing 0 at note start 26 | TRACK_ToneAdd equ 12-17 ; reset after note set 27 | TRACK_VolumeAdd equ 14-17 ; reset after note set 28 | TRACK_Noise equ 15-17 ; reset after note set 29 | TRACK_cmd_VolumeAdd equ 16-17 ; reset after note set 30 | TRACK_cmd_ToneSlideAdd equ 17-17 ; reset after note set 31 | TRACK_cmd_ToneAdd equ 19-17 ; reset after note set 32 | 33 | TRACK_cmd_detune equ 21-17 34 | TRACK_cmd_0 equ 22-17 35 | TRACK_cmd_1 equ 23-17 36 | TRACK_cmd_2 equ 24-17 37 | TRACK_cmd_3 equ 25-17 38 | TRACK_cmd_4_depth equ 26-17 39 | TRACK_cmd_4_step equ 27-17 40 | TRACK_cmd_NoteAdd equ 28-17 ;x reset after note set 41 | TRACK_cmd_A equ 29-17 42 | TRACK_cmd_B equ 30-17 43 | TRACK_cmd_E equ 31-17 44 | TRACK_Timer equ 32-17 ; used for timing by all cmd's 45 | TRACK_Step equ 33-17 ; only for VIBRATO??? 46 | TRACK_Delay equ 34-17 ; rows to wait till next data 47 | TRACK_Retrig equ 35-17 ; rows to retrigger command 48 | TRACK_prevDelay equ 36-17 49 | TRACK_cmd_A_add equ 37-17 ;<< Still in use??? 50 | 51 | TRACK_REC_SIZE equ 38 52 | 53 | 54 | B_TRGNOT equ 0 ; note trigger 55 | B_ACTNOT equ 1 ; note active 56 | B_TRGENV equ 2 ; envelope trigger 57 | B_TRGCMD equ 3 ; command active 58 | B_ACTMOR equ 4 ; morph active 59 | B_TRGINS equ 5 ; instrument trigger 60 | B_TRGWAV equ 6 ; waveform trigger 61 | B_PSGSCC equ 7 ; chip type (PSG or SCC) 62 | 63 | 64 | _SP_Storage: ds 2 ; to store the SP 65 | 66 | replay_trigger: ds 1 ; trigger byte. 67 | replay_mainPSGvol: ds 2 ; volume mixer for PSG SCC balance 68 | replay_mainSCCvol: ds 2 ; volume mixer for PSG SCC balance 69 | ;replay_songbase: ds 2 ; pointer to song data 70 | replay_wavebase: ds 2 ; pointer to waveform data 71 | replay_insbase: ds 2 ; pointer to instrument data 72 | replay_orderpointer: ds 2 ; pointer to the order track list pointers 73 | 74 | replay_speed: ds 1 ; speed to replay (get from song) 75 | replay_speed_subtimer: ds 1 ; counter for finer speed 76 | replay_speed_timer: ds 1 ; counter for speed 77 | replay_mode: ds 1 ; Replayer status 78 | ; mode 0 = no sound output 79 | ; mode 1 = replay song 80 | replay_fade: ds 1 ; Fade active (value = fade speed) 81 | replay_fade_timer: ds 1 ; Timer for fade 82 | replay_fade_vol: ds 1 ; fade volume to lower the channel volume. 83 | 84 | 85 | replay_previous_note: ds 1 ; previous note played 86 | replay_mainvol: ds 2 ; the volume correction. 87 | 88 | replay_vib_table: ds 2 ; pointer to the vibrato table 89 | replay_Tonetable: ds 2 ; ToneTable (affected by transpose); 90 | 91 | replay_morph_active: ds 1 ; flag to indicate morphing is active 92 | ;replay_morph_update: ds 1 ; flag to indicate a new waveform is ready 93 | replay_morph_timer: ds 1 ; step timer between morphs 94 | replay_morph_speed: ds 1 95 | replay_morph_counter: ds 1 ; counter till end morph 96 | replay_morph_buffer: ds 64 ; interleaved buffer with morphed waveform and morph delta values 97 | replay_morph_waveform: ds 1 ; waveform we are morphing to. 98 | 99 | 100 | TRACK_Chan1: ds TRACK_REC_SIZE 101 | TRACK_Chan2: ds TRACK_REC_SIZE 102 | TRACK_Chan3: ds TRACK_REC_SIZE 103 | TRACK_Chan4: ds TRACK_REC_SIZE 104 | TRACK_Chan5: ds TRACK_REC_SIZE 105 | TRACK_Chan6: ds TRACK_REC_SIZE 106 | TRACK_Chan7: ds TRACK_REC_SIZE 107 | TRACK_Chan8: ds TRACK_REC_SIZE 108 | 109 | TRACK_pointer1: ds 2 110 | TRACK_pointer2: ds 2 111 | TRACK_pointer3: ds 2 112 | TRACK_pointer4: ds 2 113 | TRACK_pointer5: ds 2 114 | TRACK_pointer6: ds 2 115 | TRACK_pointer7: ds 2 116 | TRACK_pointer8: ds 2 117 | 118 | 119 | ;--- AY SPECIFIC 120 | AY_registers: ds 0 121 | AY_regToneA: ds 2 ; Tone A freq low (8bit) 122 | ; Tone A freq high (4bit) 123 | AY_regToneB: ds 2 ; Tone B freq low 124 | ; Tone B freq high 125 | AY_regToneC: ds 2 ; Tone C freq low 126 | ; Tone C freq high 127 | AY_regNOISE: ds 1 ; Noise freq (5bit) 128 | AY_regMIXER: ds 1 ;0x38 ;x3f ; Mixer control (1 = off, 0 = on) 129 | AY_regVOLA: ds 1 ; Chan A volume 130 | AY_regVOLB: ds 1 ; Chan B volume 131 | AY_regVOLC: ds 1 ; Chan C volume 132 | AY_regEnvL: ds 1 ; Volume Env Freq low (8bit) 133 | AY_regEnvH: ds 1 ; Volume Env Freq high (4bit) 134 | AY_regEnvShape: ds 1 ; Volume Env Shape (4bit) 135 | 136 | ;--- SCC SPECIFIC 137 | 138 | _0x9800: ds 32 ; Waveform data 139 | _0x9820: ds 32 140 | _0x9840: ds 32 141 | _0x9860: ds 32 142 | SCC_registers: ds 0 143 | SCC_regToneA: ds 2 ; Tone A freq low (8bit) 144 | ; Tone A freq high (4bit) 145 | SCC_regToneB: ds 2 ; Tone B freq low 146 | ; Tone B freq high 147 | SCC_regToneC: ds 2 ; Tone C freq low 148 | ; Tone C freq high 149 | SCC_regToneD: ds 2 ; Tone D freq low 150 | ; Tone D freq high 151 | SCC_regToneE: ds 2 ; Tone E freq low 152 | ; Tone E freq high 153 | SCC_regVOLA: ds 1 ; Chan A volume 154 | SCC_regVOLB: ds 1 ; Chan B volume 155 | SCC_regVOLC: ds 1 ; Chan C volume 156 | SCC_regVOLD: ds 1 ; Chan D volume 157 | SCC_regVOLE: ds 1 ; Chan E volume 158 | SCC_regMIXER: ds 1 ; x3f ; Mixer control (1 = off, 0 = on) 159 | 160 | 161 | ;/// see to remove this. 162 | ;-- SCC registers 163 | oldregs: ds [32*4]+[3*5]+1 ; a way to int the SCC 164 | mapper_slot: byte 165 | SCC_slot: byte ;scc slot 166 | SCC_slot_found: byte ;scc slot where detection routine found SCC 167 | 168 | ;-- Custom vars 169 | replay_noloopmusic: ds 1 ; If 1, music stops at last pattern order track 170 | replay_musicplaying: ds 1 ; ID Number of music is playing. 171 | -------------------------------------------------------------------------------- /RAM/VIDEO.RAM: -------------------------------------------------------------------------------- 1 | ;---------------------------------------- 2 | ; Cosntantes per algunes rutines de video 3 | ;---------------------------------------- 4 | ; IPBVRSALTER 5 | SPR_FIJOS equ 0 ; Marca quants SPRITES des de el 0 no faran el flip 6 | 7 | ;------------------------------------------------ 8 | ; Variables per VDP Video 9 | ;------------------------------------------------ 10 | ; Registros VDP en RAM [Usados por MACORSVDP y cualquier acceso a Regisros VRAM] 11 | VDP_REG: ds 24 12 | ; Buffer de VIDEO 13 | VBUFF: ds 768 ; Requereix inicializar-ho. Es fa a GAME.ASM 14 | ; amb m_CLEAR_ZERO 0C000h,0F37Fh 15 | SPRRAM: ds 128 ; SPRITE RAM BUFFER (4bytes/sprite*32planos) 16 | ; Si Y = 208 no es mostren d'aquest cap endavant 17 | ; 0: CoorY 1:CoorX 18 | ; 2: Patt.Num (*4 si es 16x16) 19 | ; 3: Color 20 | SPRRAM_ROT: byte ; Control del Sprite que puju primer a VRAM 21 | VBUFF_UPDATE: byte ; Si el posem a 1 es puja VBUFF a VRAM en la interrupcio 22 | 23 | ;RAM Buffer 4 Tiles 24 | TILEBUFF: ds 8*4 ; Zona de ram per copiar tiles-sprite 25 | -------------------------------------------------------------------------------- /RAM/VIDEO_MSX2.RAM: -------------------------------------------------------------------------------- 1 | ; Video per MSX2 2 | 3 | SPRCOLRAM: ds 512 ; (32 planos * 16 filas) 4 | 5 | MSXID: byte ; 1=MSX2 o superior 0=MSX 6 | VPALETTECURRENT: byte ; Guarda el ID de la paleta actual. (Init = 1) 7 | VPALETTEMSX2: byte ; Guarda el ID de la paleta actual de MSX2. 8 | VPALETTE_DATA: ds 32 ; Guarda les dades de la paleta actual 9 | ; L'actualitaza PUTPAL 10 | SELECT_PRESS: byte ; Flag per repulsar SELECT 11 | HBLANK_LINE: byte ; Ultima linea marcada como HBLANK 12 | HBLANK_FRAMELINE: byte ; Linea on hauria d'estar el HBLANK actual 13 | 14 | SCENE_FRAME_DONE: byte ; Nos indica que acaba de pasar por VSYNC 15 | ; se pone a 1 en TIMER, lo ponemos a cero a mano 16 | SCENE_NOUSESPRITES: byte ; Indica si es 1, que no actualice sprites 17 | ; en TIMER. 18 | 19 | SCROLLVAL: byte ; Linea Actual del Scroll 20 | ; Video Commands 21 | VDPCOMDATA: ds 15 ; 0: Source XL 22 | ; 1: Source XH [Normal a cero si SCR 5] 23 | ; 2: Source YL 24 | ; 3: Source YH [Page 0-3] 25 | ; 4: Destiny XL 26 | ; 5: Destiny XH [Normal a cero si SCR 5] 27 | ; 6: Destiny YL 28 | ; 7: Destiny YH [Page 0-3] 29 | ; 8: Width XL 30 | ; 9: Width XH [Normal a cero si SCR5] 31 | ;10: Height YL 32 | ;11: Height YH [Normal a cero si SCR5] 33 | ;12: Color Register 34 | ;13: Arguments [Habitual 000000-EQ-MAJ = 00h para VRAM<->VRAM] 35 | ;14: Comando a ejecutar 36 | ; HighSpeed CMD: (Que conozco) 37 | ; 000h: Stop 38 | ; 0E0h: Highspeed Copy Vertically, VRAM -> VRAM 39 | ; 0D0h: Copy Rectangle VRAM->VRAM 40 | ; 098h: Copy Rectangle VRAM->VRAM Mask color 0 41 | ; 080h: Fill Rectangle [LineBF] 42 | ; 070h: Line normal with color 43 | ;Zona para datos de Background a cargar en Screen 5 44 | GFXDATASC5: 45 | GFXDATASC5_PAG: ds 3 ; (0,1,2) Pages 6000,8000,A000 O cero si no se usa 46 | GFXDATASC5_DIR: ds 2 ; (3-4) etiqueta de inicio de gfx 47 | GFXDATASC5_PAL: ds 2 ; (5-6) etiqueta de paleta 48 | GFXDATA_OLDPAGES: 49 | ds 3 ; Anteriores Pages 6000,8000,A000 O cero si no se usa 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TPMSX-Engine 2 | Assembler MSX Z80 Code for ROM Games by ThePetsMode 3 | 4 | ## Notes 5 | - Use https://github.com/Fubukimaru/asMSX as Assembler. 6 | - Comments are in Catalan. My native language. 7 | - Variable names in English. 8 | - This code plays a PT3 file and show a Blue screen with some colors at the bottom of the screen. Put some PT3 music file in DATA/MUSIC to compile. 9 | 10 | What's new: 11 | --- 12 | 13 | --- 14 | 15 | 2025-01 16 | 17 | - Zilog Syntax. No more custom ASMSX Syntax with [ ] 18 | - ASMSX version 1.0.1 or above compatible 19 | - Files removed: 20 | - LIB/PLY41RUT.GEN - Replaced with new version 4.2 21 | - LIB/SCREEN21.GEN 22 | - LIB/SCREEN22.GEN 23 | - LIB/TILE2SP.GEN 24 | - LIB/TILE2SP8x8.GEN 25 | - RAM/PLY41RUT.RAM 26 | - New system to access VDP with MACROS and keep a copy og VDP registers in RAM. 27 | - Added support libraries for JOYMEGA 3 and 6 buttons 28 | - Added support libraries for Trilotracker 29 | - Updates LIB/_EQUS_.GEN for MSX2 VDP 30 | - Legacy files used in Hans' Adventure: 31 | - LIB/DU.GEN 32 | - LIB/FIRE_SCN.GEN 33 | - Some new LIB files for MSX2 Stuff VDP 9938 34 | - LIB/CHECKMSX2.GEN 35 | - LIB/CLRSCR5.GEN 36 | - LIB/COMVDP.GEN 37 | - LIB/LOADSC5.GEN 38 | - LIB/MEGAROM.GEN 39 | - LIB/MSX2_PUTPAL.GEN 40 | - LIB/MSX2_SCREEN.GEN 41 | - LIB/MSX2_SPRLDPOS.GEN 42 | - LIB/MSX2_SPRLDPOS_FROMBANK.GEN 43 | - LIB/SETPAGEVIEW.GEN 44 | - LIB/SPRITES2.GEN 45 | - RAM/VIDEO_MSX2.RAM 46 | 47 | New Libraries files added: 48 | 49 | * LIB/CHECKMSX2.GEN 50 | 51 | Test if you are running on a MSX2 or not. 52 | 53 | * LIB/CLRSCR5.GEN 54 | 55 | Clear Screen 5 page with VDP Command in MSX2. 56 | 57 | * LIB/CLRSCR_SLI.GEN 58 | 59 | Slide to Right in Tile ID:0 in Screen 2-4. Using SLIDERI 60 | 61 | * LIB/COMVDP.GEN 62 | 63 | Exec a VDP command in MSX2. 64 | 65 | * LIB/GETJOYMEGA3.GEN 66 | * LIB/GETJOYMEGA6.GEN 67 | 68 | Reads JOYMEGA joysticks. 69 | 70 | * LIB/GETWASD.GEN 71 | 72 | Get WASD as Player 2 controls format. 73 | 74 | * LIB/IPBVRM.GEN 75 | 76 | Interrupt pub buffer videoram. 77 | 78 | * LIB/IRBVRM.GEN 79 | 80 | Read Bloq Video RaM. 81 | 82 | * LIB/KEY2JOY.GEN 83 | 84 | Copy keyboard for play a game (cursors/Space/M or Graph) to Joystick variable. 85 | 86 | * LIB/LOADGFX.GEN 87 | 88 | Load a full screen GFX in Screen 2. 89 | 90 | * LIB/LOADSC5.GEN 91 | 92 | Load a full screen GFX in Screen 5. 93 | 94 | * LIB/MEGAROM.GEN 95 | 96 | Prepare some variabler to load Screen 5 images from Konami4 Megarom pages 97 | 98 | * LIB/MULT.GEN 99 | 100 | MUL 8 bits x 8 bits. 101 | 102 | * LIB/MSX2_PUTPAL.GEN 103 | 104 | Palette MSX2 Routines 105 | 106 | * LIB/MSX2_SCREEN.GEN 107 | 108 | V9938 MSX2 Routines to set screen parameters 109 | 110 | * LIB/MSX2_SPRLDPOS_FROMBANK.GEN 111 | 112 | SPRiTes pattern LoaD to POSition 113 | 114 | * LIB/MSX2_SPRLDPOS_FROMBANK.GEN 115 | 116 | SPRiTes pattern LoaD FROM a ROM BANK label to POSition 117 | 118 | * LIB/PLY42RUT.GEN 119 | 120 | New version of ZMA Player by The Pets Mode. 121 | 122 | * LIB/PUTGFX_TILETRANS.GEN 123 | 124 | Copy tiles to VRAM Screen 2 without a ID tile as transparent. 125 | 126 | * LIB/RANDOM.GEN 127 | 128 | Generates a good random number. 129 | 130 | * LIB/SETPAGEVIEW.GEN 131 | 132 | Set Page view in screen 5 VDP 9938 MSX2 133 | 134 | * LIB/SCREEN.GEN 135 | 136 | New libary to change screen mode, On/Off and solid 0 color in MSX2. 137 | 138 | * LIB/SLOT3ROM.GEN 139 | 140 | For use 64ks ROMS by Imanok. 141 | 142 | * LIB/SPRITES2.GEN 143 | 144 | PUT SPRITE for MSX2 (Screen4...8). 145 | 146 | * LIB/SPRLDPOS.GEN 147 | 148 | SPRiTes pattern LoaD to POSition. 149 | 150 | * LIB/TTREPLAY.GEN 151 | * LIB/TTREPLAYDAT.GEN 152 | * LIB/TTSCCDETECT.GEN 153 | * LIB/TTvoltable_combined.bin 154 | * RAM/TTREPLAY.RAM 155 | 156 | Replays for SCC+PSG TriloTracker re-player v0.3.1. 157 | SCC-search v1.0 by Alwin Henseler. 158 | 159 | * SRC/MACROS.ASM 160 | 161 | A collection of Macros Added (Use ASMSX version 1.0.1 or above). 162 | 163 | --- 164 | 165 | 2019-07 166 | 167 | * LIB/PT3PLAYER.GEN 168 | * RAM/PT3PLAYER.RAM 169 | 170 | Added PT3_SECOND and PT3_FRAME for music control 171 | 172 | * LIB/SLIDERI.GEN 173 | 174 | Fade to Right (tile to tile) HAVE HALTS inside! 175 | 176 | * LIB/SPRT16HFLIP.GEN 177 | 178 | Flip Sprite pattern data horizontaly in RAM 179 | 180 | * GAMETIMER.GEN 181 | 182 | Adding and control PT3_SECOND and PT3_FRAME for music 183 | 184 | * GAMEMOTOR.GEN 185 | 186 | Initialize PT3_PATTERN_POS, PT3_SECOND and PT3_FRAME 187 | 188 | * GAME.ASM 189 | 190 | Init VBUFF_UPDATE to 0. 191 | 192 | Call to PT3_STOP before game starts 193 | ____PAGE3 tags for best debug 194 | 195 | --- 196 | 197 | 2017: 198 | First Version 199 | -------------------------------------------------------------------------------- /RENAME.BAT: -------------------------------------------------------------------------------- 1 | @copy *.z80 *.rom /Y -------------------------------------------------------------------------------- /SRC/MACROS.ASM: -------------------------------------------------------------------------------- 1 | ; MACROS para TPMADV Engine 2 | 3 | m_INC16: MACRO #VARIABLE 4 | push HL 5 | ld HL,#VARIABLE 6 | inc (HL) 7 | pop HL 8 | ENDM 9 | 10 | m_RESET16: MACRO #VARIABLE 11 | push HL 12 | ld HL,#VARIABLE 13 | ld (HL),0 14 | pop HL 15 | ENDM 16 | 17 | m_INCVALUE_MAX: MACRO #VARBIABLE,#MAX 18 | ld A,(#VARBIABLE) 19 | inc A 20 | cp #MAX 21 | jr nz,.noreset_#VARBIABLE 22 | xor A 23 | .noreset_#VARBIABLE: 24 | ld (#VARBIABLE),A 25 | ENDM 26 | 27 | m_INCVALUE_MAX_KEEP: MACRO #VARBIABLE,#MAX 28 | ld A,(#VARBIABLE) 29 | cp #MAX 30 | jr z,.noinc_#VARBIABLE 31 | inc A 32 | ld (#VARBIABLE),A 33 | .noinc_#VARBIABLE: 34 | ENDM 35 | 36 | m_INCVALUE_MAX_RESET: MACRO #VARBIABLE,#MAX,#RESETVALUE 37 | ld A,(#VARBIABLE) 38 | inc A 39 | cp #MAX 40 | jr nz,.noreset_#VARBIABLE 41 | ld A,#RESETVALUE 42 | .noreset_#VARBIABLE: 43 | ld (#VARBIABLE),A 44 | ENDM 45 | 46 | m_ADDVALUE_MAX: MACRO #VARBIABLE,#VALUE,#MAX 47 | ld A,(#VARBIABLE) 48 | add A,#VALUE 49 | cp #MAX 50 | jr nz,.noreset_#VARBIABLE 51 | xor A 52 | .noreset_#VARBIABLE: 53 | ld (#VARBIABLE),A 54 | ENDM 55 | 56 | m_SOUND: MACRO #SONIDO,#DURACION 57 | push HL 58 | push BC 59 | ld C,#DURACION 60 | ld HL,#SONIDO 61 | call PLAYFX 62 | pop BC 63 | pop HL 64 | ENDM 65 | 66 | m_DO_EVENTS: MACRO #LIST_EVENTS 67 | push IX 68 | ld IX,#LIST_EVENTS 69 | call RUNEVENTS 70 | pop IX 71 | ENDM 72 | 73 | m_CLEAR_ZERO: MACRO #INIT,#END 74 | push BC 75 | push HL 76 | push DE 77 | ld BC, #END - [#INIT+1] 78 | ld HL, #INIT 79 | ld DE, #INIT +1 80 | ld (HL),0 81 | ldir 82 | pop DE 83 | pop HL 84 | pop BC 85 | ENDM 86 | 87 | m_CLEAR_VBUFF_WITH: MACRO #DATA 88 | ld BC, [VBUFF+768] - [VBUFF+1] 89 | ld HL, VBUFF 90 | ld DE, VBUFF +1 91 | ld (HL),#DATA 92 | ldir 93 | ENDM 94 | 95 | m_CLEAR_LINES_VBUFF_WITH: MACRO #DATA,#INIT,#LINES 96 | ld BC, [VBUFF+#INIT*32+#LINES*32] - [VBUFF+1+#INIT*32] 97 | ld HL, [VBUFF+#INIT*32] 98 | ld DE, [VBUFF+#INIT*32+1] 99 | ld (HL),#DATA 100 | ldir 101 | ENDM 102 | 103 | ; Marco para que se actualice VRAM 104 | m_VBUFF_READY: MACRO 105 | ld A,1 106 | ld (VBUFF_UPDATE),A 107 | ENDM 108 | 109 | 110 | m_LOAD_3BANKS: MACRO #PATTERNS,#COLORS 111 | ; WARNING!! need DI 112 | ld HL,#PATTERNS 113 | ld DE,VRM_PAT 114 | call IWBVRMRLE2 115 | ld HL,#PATTERNS 116 | ld DE,VRM_PAT+2048 117 | call IWBVRMRLE2 118 | ld HL,#PATTERNS 119 | ld DE,VRM_PAT+4096 120 | call IWBVRMRLE2 121 | ld HL,#COLORS 122 | ld DE,VRM_COL 123 | call IWBVRMRLE2 124 | ld HL,#COLORS 125 | ld DE,VRM_COL+2048 126 | call IWBVRMRLE2 127 | ld HL,#COLORS 128 | ld DE,VRM_COL+4096 129 | call IWBVRMRLE2 130 | ENDM 131 | 132 | m_PUTGFX_RAM: MACRO #GFX,#X,#Y,#TARGET 133 | ld IX,#GFX 134 | ld IY,#TARGET+#X+32*#Y 135 | call PUTGFX 136 | ENDM 137 | 138 | m_PUTGFX_TRANS: MACRO #GFX,#X,#Y,#TARGET,#TRANS 139 | ld IX,#GFX 140 | ld IY,#TARGET+#X+32*#Y 141 | ld C,#TRANS 142 | call PUTGFX_TRANS 143 | ENDM 144 | 145 | m_PUTGFX_SC5: MACRO #GFX,#X,#Y,#PAG 146 | ; #X Ha de ser Pixel parell 0,2,4,6,... 147 | ld B,#PAG 148 | ld HL,(#GFX) 149 | ld DE,VRM_BIT+[#Y*128]+[#X/2] 150 | call IWBVRM5RLE2 151 | ENDM 152 | 153 | m_COPY_SC5: MACRO #X,#Y,#DEST_PAG 154 | ; Espera Puntero a GFXSC5 en IY 155 | ld B,#X ; X 156 | ld C,#Y ; Y 157 | ld IX,VDPCOMDATA 158 | ld A,(IY) 159 | ld (IX+0), A ;SXL 160 | ld (IX+1), 0 ;SXH 161 | ld A,(IY+1) 162 | ld (IX+2), A ;SYL 163 | ld A,(IY+4) 164 | ld (IX+3), A ;SYH Page 165 | ld (IX+4), B ;DXL 166 | ld (IX+5), 0 ;DXH 167 | ld (IX+6), C ;DYL 168 | ld (IX+7), #DEST_PAG ;DYH Page 169 | ld A,(IY+2) 170 | ld (IX+8), A ;INCXL 171 | ld (IX+9), 0 ;INCXH 172 | ld A,(IY+3) 173 | ld (IX+10), A ;INCYL 174 | ld (IX+11), 0 ;INCYH 175 | ;ld (IX+12), 0 ;Color register no se usa 176 | ld (IX+13), 0 ;ARG Para este caso SIEMPRE 0 177 | ld (IX+14), CMDCOPY ; Copy Rectangle VRAM->VRAM 178 | ld HL,VDPCOMDATA ; Envio CMD 179 | call _VDPCMD 180 | ENDM 181 | 182 | m_COPYMASK_SC5: MACRO #X,#Y,#DEST_PAG 183 | ; Espera Puntero a GFXSC5 en IY 184 | ld B,#X ; X 185 | ld C,#Y ; Y 186 | ld IX,VDPCOMDATA 187 | ld A,(IY) 188 | ld (IX+0), A ;SXL 189 | ld (IX+1), 0 ;SXH 190 | ld A,(IY+1) 191 | ld (IX+2), A ;SYL 192 | ld A,(IY+4) 193 | ld (IX+3), A ;SYH Page 194 | ld (IX+4), B ;DXL 195 | ld (IX+5), 0 ;DXH 196 | ld (IX+6), C ;DYL 197 | ld (IX+7), #DEST_PAG ;DYH Page 198 | ld A,(IY+2) 199 | ld (IX+8), A ;INCXL 200 | ld (IX+9), 0 ;INCXH 201 | ld A,(IY+3) 202 | ld (IX+10), A ;INCYL 203 | ld (IX+11), 0 ;INCYH 204 | ;ld (IX+12), 0 ;Color register no se usa 205 | ld (IX+13), 0 ;ARG Para este caso SIEMPRE 0 206 | ld (IX+14), CMDCOPY0 ; Copy Rectangle VRAM->VRAM Mask color 0 207 | ld HL,VDPCOMDATA ; Envio CMD 208 | call _VDPCMD 209 | ENDM 210 | 211 | ; USE RECOVER after a CHANGE !! 212 | ; #MEMDIR 6000, 8000, 0A000 213 | m_CHANGE_TOSUBPAGE: MACRO #SUBP,#MEMDIR 214 | ld A,(#MEMDIR) 215 | push AF 216 | ld A,#SUBP 217 | ld (#MEMDIR+01000h),A 218 | ENDM 219 | 220 | m_RECOVER_SUBPAGE: MACRO #MEMDIR 221 | pop AF 222 | ld (#MEMDIR+01000h),A 223 | ENDM 224 | 225 | m_MANUAL_IE: MACRO #TAGTOEXIT 226 | ; Anem a llegir el Registre S1, posem el 1 al Registre 0fh 227 | ld A,1 ; Registre Status 1 228 | out (99h),A 229 | ld A,80h + 0Fh ; Registre 0fh 230 | out (99h),A 231 | in A,(99h) ; El bit 0, marca si hi ha HSync 232 | and 1 233 | jr nz,.MAKE_IE 234 | ld A,2 ; return 2. No es fa la IE 235 | jp .next#TAGTOEXIT 236 | .MAKE_IE: 237 | push BC 238 | push DE 239 | push HL 240 | ;------------ 241 | ld A,MAXY_SCREEN 242 | ld B,A 243 | ld A,(V_SCN_INTRO_SCROLLROW) 244 | add A,B 245 | ld B,A 246 | ld A,(HBLANK_LINE) 247 | cp B 248 | jr z,.HBLANK_2 249 | ;Posem la paleta del UI al 144 250 | ld HL,PAL_UI_STAN 251 | xor A 252 | out (99h),A 253 | ld A,080h+10h ; a Registre 10h Color inicial 254 | out (99h),A 255 | ld C,9Ah ; 32 vegades a port 9A 256 | REPT 32 257 | outi 258 | ENDR 259 | ld A,MAXY_SCREEN 260 | ; Teniendo en cuenta el registro de Scroll 261 | ld B,A 262 | ld A,(V_SCN_INTRO_SCROLLROW) 263 | add A,B 264 | ld (HBLANK_LINE),A 265 | out (99h),A 266 | ld A,80h + 13h 267 | out (99h),A 268 | ld A,1 ; return 1. No es fa UI al HBLANK_LINE 269 | jp .END 270 | .HBLANK_2: 271 | ; La paleta que toque del grafico 272 | ld HL, (GFXDATASC5_PAL) 273 | xor A 274 | out (99h),A 275 | ld A,080h+10h ; a Registre 10h Color inicial 276 | out (99h),A 277 | ld C,9Ah ; 32 vegades a port 9A 278 | ; Sin esperas pq VDP del MSX2 no las requiere. 279 | REPT 32 280 | outi 281 | ENDR 282 | ld A,(HBLANK_FRAMELINE) 283 | ld B,A 284 | ld A,(V_SCN_INTRO_SCROLLROW) 285 | add A,B 286 | ld (HBLANK_LINE),A 287 | out (99h),A 288 | ld A,80h + 13h 289 | out (99h),A 290 | ;SELECT 1 AT 06000h con el sistema de ID de subslot 291 | ld A,(06000h) 292 | push AF 293 | ld A,1 294 | ld (07000h),A 295 | ;SELECT 22 AT 0A000h con el sistema de ID de subslot 296 | ld A,(0A000h) 297 | push AF 298 | ld A,22 299 | ld (0B000h),A 300 | call replay_route ; first outout data 301 | call replay_play ; calculate next output 302 | ; Recupera subpage 303 | pop AF 304 | ld (0B000h),A 305 | ; Recupera subpage 306 | pop AF 307 | ld (07000h),A 308 | xor A ; return 0 309 | ;------------ 310 | .END: 311 | pop HL 312 | pop DE 313 | pop BC 314 | .next#TAGTOEXIT: 315 | ENDM 316 | 317 | m_PUTSPRITE: MACRO #PATTERN,#X,#Y,#PLANO,#COLOR 318 | ld HL,[#Y*256+#X] ; Y,X 319 | ld D,#PATTERN*4 ; Pattern 320 | ld E,#COLOR ; Color 321 | ld C,#PLANO ; Plano 322 | call PUTSPRT 323 | ENDM 324 | 325 | m_PUTSPRITE_VARXY: MACRO #PATTERN,#X,#Y,#PLANO,#COLOR 326 | ld A,(#X) 327 | ld L,A 328 | ld A,(#Y) 329 | ld H,A 330 | ;ld HL,[#Y*256+#X] ; Y,X 331 | ld D,#PATTERN*4 ; Pattern 332 | ld E,#COLOR ; Color 333 | ld C,#PLANO ; Plano 334 | call PUTSPRT 335 | ENDM 336 | 337 | m_EVENTENTRY: MACRO #VAR,#UPDATE 338 | ld A,(#VAR) 339 | or A 340 | jr nz,#UPDATE 341 | ld A,1 342 | ld (#VAR),A 343 | ENDM 344 | 345 | 346 | 347 | m_PUTSP32: MACRO #PATTERN,#X,#Y,#PLANO,#COLOR,#ZOOM 348 | ld HL,[#Y*256+#X] ; Y,X 349 | ld D,#PATTERN ; Pattern 350 | ld E,#COLOR ; Color 351 | ld C,#PLANO ; Plano 352 | call PUTSPRT 353 | ld HL,[#Y*256+#X+#ZOOM] ; Y,X 354 | ld D,[#PATTERN+1]*4 ; Pattern 355 | ld E,#COLOR ; Color 356 | ld C,#PLANO+1 ; Plano 357 | call PUTSPRT 358 | ld HL,[[#Y+#ZOOM]*256+#X] ; Y,X 359 | ld D,[#PATTERN+2]*4 ; Pattern 360 | ld E,#COLOR ; Color 361 | ld C,#PLANO+2 ; Plano 362 | call PUTSPRT 363 | ld HL,[[#Y+#ZOOM]*256+#X+#ZOOM] ; Y,X 364 | ld D,[#PATTERN+3]*4 ; Pattern 365 | ld E,#COLOR ; Color 366 | ld C,#PLANO+3 ; Plano 367 | call PUTSPRT 368 | ENDM 369 | 370 | m_MANUAL_IE_PT3: MACRO #NUMPAGE,#DIR,#TAGTOEXIT 371 | ; Anem a llegir el Registre S1, posem el 1 al Registre 0fh 372 | ld A,1 ; Registre Status 1 373 | out (99h),A 374 | ld A,10001111b ; Registre 0fh 375 | out (99h),A 376 | in A,(99h) ; El bit 0, marca si hi ha HSync 377 | and 1 378 | jr z,.next#TAGTOEXIT 379 | push BC 380 | push DE 381 | push HL 382 | ld A,(6000h) 383 | push AF 384 | SELECT #NUMPAGE AT #DIR 385 | call TIMER_PLAYER_FULL 386 | pop AF 387 | SELECT A AT #DIR 388 | pop HL 389 | pop DE 390 | pop BC 391 | .next#TAGTOEXIT: 392 | ENDM 393 | 394 | m_CHANGE_INTERRUPT: MACRO #NEWINTERRUPT 395 | ld HL,0FD9Ah 396 | ld BC,#NEWINTERRUPT 397 | ld (HL),0C3h 398 | inc HL 399 | ld (HL),C 400 | inc HL 401 | ld (HL),B 402 | ENDM 403 | -------------------------------------------------------------------------------- /UPDATES.TXT: -------------------------------------------------------------------------------- 1 | What's new: 2 | ------------ 3 | 2019-07 4 | 5 | * LIB/PT3PLAYER.GEN 6 | * RAM/PT3PLAYER.RAM 7 | Added PT3_SECOND and PT3_FRAME for music control 8 | 9 | *LIB/SLIDERI.GEN 10 | Fade to Right (tile to tile) HAVE HALTS inside! 11 | 12 | *LIB/SPRT16HFLIP.GEN 13 | Flip Sprite pattern data horizontaly in RAM 14 | 15 | *GAMETIMER.GEN 16 | Adding and control PT3_SECOND and PT3_FRAME for music 17 | 18 | *GAMEMOTOR.GEN 19 | Initialize PT3_PATTERN_POS, PT3_SECOND and PT3_FRAME 20 | 21 | *GAME.ASM 22 | Init VBUFF_UPDATE to 0 23 | call to PT3_STOP before game starts 24 | ____PAGE3 tags for best debug 25 | 26 | 2017: 27 | First Version --------------------------------------------------------------------------------