processor 6502 include "vcs.h" include "macro.h" MAC Linea1old LDX #4 ; 192 Scanlines to Display LDY #0 .Draw_Picture LDA #8 STA $80 .DoblePasada STA WSYNC LDA {1},Y STA PF0 LDA Cero,Y STA PF1 LDA {2},Y STA PF2 SLEEP 4 LDA {3},Y STA PF0 LDA Cero,Y STA PF1 LDA {4},Y STA PF2 DEC $80 BNE .DoblePasada INY DEX BNE .Draw_Picture JMP Retorno ENDM MAC Linea2old LDX #4 ; 192 Scanlines to Display LDY #0 .Draw_Picture2 LDA #8 STA $80 .DoblePasada2 STA WSYNC LDA {1},Y STA PF0 LDA Cero,Y STA PF1 LDA {2},Y STA PF2 SLEEP 4 LDA {3},Y STA PF0 LDA Cero,Y STA PF1 LDA {4},Y STA PF2 DEC $80 BNE .DoblePasada2 INY DEX BNE .Draw_Picture2 JMP Retorno2 ENDM MAC Linea1 LDA <#{1} STA $92 LDA >#{1} STA $93 LDA <#{2} STA $94 LDA >#{2} STA $95 LDA <#{3} STA $96 LDA >#{3} STA $97 LDA <#{4} STA $98 LDA >#{4} STA $99 JSR Linea JMP Retorno ENDM MAC Linea2 LDA <#{1} STA $92 LDA >#{1} STA $93 LDA <#{2} STA $94 LDA >#{2} STA $95 LDA <#{3} STA $96 LDA >#{3} STA $97 LDA <#{4} STA $98 LDA >#{4} STA $99 JSR Linea JMP Retorno2 ENDM Gris = 8 Marron = 4*8 Verde = 3*16 + 10 Naranja = 4*16 + 10 Celeste = 9*16 + 14 Azul = 11*16 + 4 Amarillo = 2*16 + 14 ; es amarillo? Rojo = 6*16 + 4 ; es rojo? PunteroRoom = $86 PunteroRoomBKP = $8C TieneObjeto = 1 Guante = 2 Lamp = 4 Llave = 8 PushQ = 16 Dia2 = 32 Inventario = $8E ControlBoton = $8F Temp = $91 ScanLine1 = $9A ScanLine2 = $9B ScanLine3 = $9C ScanLine4 = $9D ScanLine5 = $9E ScanLine6 = $9F ScanLine7 = $A0 ScanLine8 = $A1 ScanLine9 = $A2 ScanLine10 = $A3 ScanLine11 = $A4 ScanLine12 = $A5 ScanLine13 = $A6 ScanLine14 = $A7 ScanLine1_2 = $A8 ScanLine2_2 = $A9 ScanLine3_2 = $AA ScanLine4_2 = $AB ScanLine5_2 = $AC ScanLine6_2 = $AD ScanLine7_2 = $AE ScanLine8_2 = $AF ScanLine9_2 = $B0 ScanLine10_2 = $B1 ScanLine11_2 = $B2 ScanLine12_2 = $B3 ScanLine13_2 = $B4 ScanLine14_2 = $B5 ;///////////////// Start of Code ///////////////////////////////////// SEG ORG $F000 Reset ; Clear RAM, TIA registers and Set Stack Pointer to #$FF SEI CLD LDX #$FF TXS LDA #0 Clear_Mem STA 0,X DEX BNE Clear_Mem LDA #$00 STA COLUBK ; Set Background to Black LDA #TieneObjeto STA Inventario LDA #2 STA $81 LDA <#0;Habitacion1 STA PunteroRoom STA PunteroRoomBKP LDA >#0;Habitacion1 STA PunteroRoom + 1 STA PunteroRoomBKP + 1 LDA <#Cursor1 STA $82 LDA >#Cursor1 STA $83 LDA <#Cursor2 STA $84 LDA >#Cursor2 STA $85 LDA <#DibujaHabitacion3;Calle1 STA $88 LDA >#DibujaHabitacion3;Calle1 STA $89 LDY #0 LDX #36;13 ;14 jmp llens Llenar LDA #0;Barras1,Y STA ScanLine1,X ;LDA Barras2,Y ;STA ScanLine1_2,X INY DEX BNE Llenar llens lda #0 sta ControlBoton lda #1 sta Temp lda #128 sta PunteroRoomBKP + 1 jsr Trace ;/////////////////// Picture Starts Here ///////////////////////////// Start_Frame LDA #8 STA COLUPF ; Start VSYNC LDA #2 STA VSYNC STA WSYNC STA WSYNC STA WSYNC ; 3 Scanlines of VSYNC LDA #0 STA VSYNC ; End VSYNC ; 37 Scanlines of Vertical Blank... LDX #37 Vertical_Blank STA WSYNC DEX BNE Vertical_Blank LDA #0 STA VBLANK ; Enable TIA Output ;////////////// Start To Draw Playfield /////////////////////////////// LDX #4 ; Frase 1 empieza mas arriba Tiempo STA WSYNC DEX BNE Tiempo JMP ($82);Frase1 Retorno LDA Cero STA PF0 STA PF1 STA PF2 STA WSYNC STA WSYNC STA WSYNC STA WSYNC STA WSYNC STA WSYNC JMP ($84);Frase2 Retorno2 LDA Cero STA PF0 STA PF1 STA PF2 LDA #1 STA CTRLPF JMP ($88) Retorno3 LDA #0 STA CTRLPF LDA Cero STA PF0 STA PF1 STA PF2 ldy #17;9 DibuMapi lda Mapita,y cpy Temp beq HayMap jmp HayMaps HayMap ora PunteroRoomBKP + 1 HayMaps sta WSYNC sta GRP0 lda Mapita2,y cpy Temp beq HayMap2 jmp HayMap2s HayMap2 ora $90 HayMap2s sta GRP1 sta RESP0 sta RESP1 dey bne DibuMapi ;LDX #184 LDX #50;60;70;80;90 ;112 DibujaCola STA WSYNC DEX BNE DibujaCola LDA SWCHA AND #%10000000 BEQ Decision3 LDA SWCHA AND #%01000000 BEQ Decision LDA SWCHA AND #%00010000 BEQ Decision2 LDA SWCHA AND #%00100000 BEQ Decision4 LDA INPT4 BMI RetDeci BNE Boton ;Decision ;TogImg ; LDA $90 ; CMP #1 ; BEQ Uno ; LDA #1 ; STA $90 ; JMP RetDeci ;Uno ; LDA #0 ; STA $90 RetDeci ;////////////// End Of Display //////////////////////////////////////// LDA #%01000010 ; Disable VIA Output STA VBLANK ; 30 scanlines of overscan... LDX #10 Overscan STA WSYNC DEX BNE Overscan ; LDA $90 ; CMP #1 ; BEQ MostraImg JMP Start_Frame ;MostraImg ; JMP Start_Frame0 ; Build Next Frame ; Playfield generated by TIA Playfield Painter ; Mode Used = ASYMMETRICAL ; Playfields generated = PF0, PF1, PF2, PF3, PF4, PF5 ; Datas lines are reversed ; 192 Line(s) saved = 191 - 0 Decision3 lda PunteroRoom + 1 clc adc #241 sta PunteroRoom + 1 dec Temp clc ror PunteroRoomBKP + 1 ror $90 jsr Trace jmp RetDeci Decision lda PunteroRoom + 1 clc adc #15 sta PunteroRoom + 1 inc Temp clc rol $90 rol PunteroRoomBKP + 1 jsr Trace jmp RetDeci Boton jmp RetDeci Decision2 lda PunteroRoom + 1 clc adc #17 sta PunteroRoom + 1 inc Temp clc ror PunteroRoomBKP + 1 ror $90 jsr Trace jmp RetDeci Decision4 lda PunteroRoom + 1 clc adc #239 sta PunteroRoom + 1 dec Temp clc rol $90 rol PunteroRoomBKP + 1 jsr Trace jmp RetDeci Cero .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 Flecha .byte #%01000000 .byte #%11100000 .byte #%01000000 .byte #%01000000 Flecha2 .byte #%0000010 .byte #%0000111 .byte #%0000010 .byte #%0000010 Cursor1 Linea1 Flecha,Cero,Cero,Cero Cursor2 Linea2 Cero,Flecha2,Cero,Cero ALIGN 256 Habitacion1 .word Cursor1 .word Cursor2 .word Cursor1 .word Cursor2 .word #TieneObjeto .word #TieneObjeto .word #TieneObjeto .word #TieneObjeto .word #TieneObjeto .word #TieneObjeto .word #TieneObjeto .word #TieneObjeto .word Habitacion1 .word Habitacion1 .word Habitacion1 .word Habitacion1 ScanL0 .byte #0 Barras1 .byte #%11111111 .byte #%11111111 .byte #%01111111 .byte #%01111111 .byte #%00111111 .byte #%00111111 .byte #%00011111 .byte #%00011111 .byte #%00001111 .byte #%00001111 .byte #%00000111 .byte #%00000111 .byte #%00000011 .byte #%00000011 .byte #%00000001 .byte #%00000001 .byte #%00000001 Colores .byte #1 .byte #1 .byte #1 .byte #1 .byte #2 .byte #2 .byte #2 .byte #2 .byte #3 .byte #3 .byte #3 .byte #3 .byte #4 .byte #4 .byte #4 .byte #4 .byte #5 .byte #5 .byte #5 .byte #5 .byte #6 .byte #6 .byte #6 .byte #6 .byte #7 .byte #7 .byte #7 .byte #7 .byte #7 .byte #7 Linea LDX #4 ; 192 Scanlines to Display LDY #0 Draw_Picture LDA #8 STA $80 DoblePasada STA WSYNC LDA ($92),Y STA PF0 LDA Cero,Y STA PF1 LDA ($94),Y STA PF2 SLEEP 4 LDA ($96),Y STA PF0 LDA Cero,Y STA PF1 LDA ($98),Y STA PF2 DEC $80 BNE DoblePasada INY DEX BNE Draw_Picture RTS DibujaHabitacion3 lda #16;13;7 sta Inventario lda #16;36;13 sec sbc ControlBoton sta PunteroRoom ldx PunteroRoom ldy PunteroRoom ;LDX #13; 14 ; 192 Scanlines to Display ;LDY #0 LDA #Celeste ;SBC #13 ;STA $90 ;LDA #Verde ;SBC #11 ;LDA #0 ;STA $91 ;A0 Draw_PictureW LDA #4 STA $80 ;LDA $90 ;ADC #1 ;STA $90 ;INC $90 ;INC $91 ;A0 DoblePasadaW ;STX COLUPF ;LDA $91 ;A0 LDA ScanLine1 + 37,y ;Colores,Y STA COLUPF LDA #Gris ;$90 STA COLUBK STA WSYNC LDA ScanL0 STA PF0 LDA ScanLine1,X STA PF1 ;LDA #0;255;ScanLine1_2,X STA PF2 sleep 24 LDA #0 ;stx PunteroRoomBKP ;txa ;adc #13 ;tax ;lda ScanLine1,X ;ldx PunteroRoomBKP ;sleep 10 STA PF1 STA PF2 DEC $80 BNE DoblePasadaW dey;INY DEX beq lim jmp lims lim ldx #36;13 ldy #36;13 lims dec Inventario BNE Draw_PictureW JMP Retorno3 Ancho .byte 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 .byte 15,12, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0 .byte 4, 9, 8, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 0, 0 .byte 4, 1, 7, 6, 2, 1, 1, 1, 2, 1, 1, 1, 1, 0, 0, 0 .byte 4, 1, 1, 5, 3, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0 .byte 4, 2, 2, 4, 5, 2, 1, 1, 2, 1, 1, 0, 0, 0, 0, 0 .byte 3, 1, 1, 1, 3, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 .byte 3, 1, 1, 1, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0 .byte 3, 1, 1, 1, 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0 .byte 3, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Luz .byte 1,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 .byte 1, 4,13,13,13,14,14,14,14,15,15,15,15,15,15, 0 .byte 1, 4, 5,12,12,13,13,13,13,14,14,14,14,14, 0, 0 .byte 1, 4, 5, 6,11,12,12,12,12,13,13,13,13, 0, 0, 0 .byte 1, 4, 5, 6, 9,11,11,11,11,12,12,12, 0, 0, 0, 0 .byte 1, 3, 4, 5, 6, 9,10,10,10,11,11, 0, 0, 0, 0, 0 .byte 1, 3, 4, 5, 6, 8, 9,10,10,10, 0, 0, 0, 0, 0, 0 .byte 1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0 .byte 1, 3, 4, 5, 6, 7, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Distancia .byte 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16 .byte 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 0 .byte 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 0, 0 .byte 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 0, 0, 0 .byte 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 0, 0, 0, 0 .byte 6, 7, 8, 9,10,11,12,13,14,15,16, 0, 0, 0, 0, 0 .byte 7, 8, 9,10,11,12,13,14,15,16, 0, 0, 0, 0, 0, 0 .byte 8, 9,10,11,12,13,14,15,16, 0, 0, 0, 0, 0, 0, 0 .byte 9,10,11,12,13,14,15,16, 0, 0, 0, 0, 0, 0, 0, 0 .byte 10,11,12,13,14,15,16, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 11,12,13,14,15,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 12,13,14,15,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 13,14,15,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 14,15,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 15,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Mapa ; .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; .byte 0, 0, 0, 0, 0, 0, 0, 0,99,99, 0, 0, 0, 0, 0, 0 ; .byte 0, 0, 0, 0, 0, 0,99,99, 0, 0,99,99, 0, 0, 0, 0 ;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0, 0,99, 0, 0, 0, 0, 0,99, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0,99, 0, 0, 0,99, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0,99, 0,99, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0,99, 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Trace ldx #36 Borra lda #0 sta ScanLine1,x dex bne Borra ldy #255 tr sty PunteroRoomBKP lda Luz,y jsr Mover cmp Mapa,y bmi Hay ldy PunteroRoomBKP dey bne tr rts Hay ldy PunteroRoomBKP ldx Luz,y beq jup sty PunteroRoomBKP lda Ancho,y sta $92 sta $94 lda Distancia,y tay lda Barras1,y stx $93 repeline sta ScanLine1,x inx dec $92 bne repeline ldx $93 lda Colores,y repeline2 sta ScanLine1 + 37,x inx dec $94 bne repeline2 ldy PunteroRoomBKP jup dey bne tr rts Mover ;ldx PunteroRoom + 1 ;bne Mover2 ;rts ;Mover2 ; iny ; dex ; bne Mover2 sta PunteroRoom tya clc adc PunteroRoom + 1 tay lda PunteroRoom rts ListaDeRumbos .byte #255 .byte #255 .byte #255 .byte #255 .byte #239 .byte #239 .byte #239 .byte #239 .byte #239 .byte #240 .byte #240 .byte #240 .byte #240 .byte #241 .byte #241 .byte #241 .byte #241 .byte #241 .byte #1 .byte #1 .byte #1 .byte #1 .byte #17 .byte #17 .byte #17 .byte #17 .byte #17 .byte #16 .byte #16 .byte #16 .byte #16 .byte #15 .byte #15 .byte #15 .byte #15 .byte #15 Mapita .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000001 .byte #%00000000 .byte #%00000000 .byte #%00010000 .byte #%00001000 .byte #%00000100 .byte #%00000010 .byte #%00000001 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 Mapita2 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%10000000 .byte #%01000000 .byte #%00100000 .byte #%00010000 .byte #%00100000 .byte #%01000000 .byte #%10000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 .byte #%00000000 ;////////////// Set Vectors /////////////////////////////////////////// ORG $FFFA ; Interrupt Vectors .word Reset ; NMI .word Reset ; RESET .word Reset ; IRQ END