Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INIT and MAIN JSL targets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "INIT"
JSR SPRITE_INIT_ROUTINE
RTL
dcb "MAIN"
JSR SPRITE_MAIN_ROUTINE
RTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SPRITE_ROUTINE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPRITE_INIT_ROUTINE:
STZ $0F62
STZ $0F63
RTS
SPRITE_MAIN_ROUTINE:
LDA #$80
STA $0DAC
STA $0DAD
LDA $7B
BNE ANotPressed
LDA $72
BNE ANotPressed
LDA $71
BNE ANotPressed
LDA $77
AND #$04
BEQ ANotPressed
LDA $0F62
CMP #$01
BEQ MoveRoutine
LDA $0F62
CMP #$01
BCC SpriteToMario
LDA $0F62
CMP #$01
BCS MarioToSprite
RTS
SpriteToMario:
LDA $94 ;\
STA $E4,x ;|Sprite gets Mario position
LDA $95 ;|
STA $14E0,x ;|
LDA $96 ;|
STA $D8,x ;|
LDA $97 ;|
STA $14D4,x ;/
LDA $17
AND #$80
BNE TESTB
LDA #$01
STA $0F63
TESTB:
LDA $0F63
BEQ ANotPressed
LDA $17 ;\
;AND #$80 ;|If A is pressed go next time to sprite move routine
CMP #$80
BNE ANotPressed ;|
LDA #$01 ;|
STA $0F63 ;|
STA $0F62 ;|
ANotPressed: ;|
RTS ;/
MarioToSprite:
STZ $0F62
LDA $E4,x ;\
STA $94 ;| Mario gets Sprite position
LDA $14E0,x ;|
STA $95 ;|
LDA $D8,x ;|
STA $96 ;|
LDA $14D4,x ;|
STA $97 ;/
LDA #$29
STA $1DFC
STZ $18BD
STZ $9D
RTS
MoveRoutine:
LDA #$FF
STA $18BD
STA $9D
STZ $7D ;|
STZ $7B ;/
LDA $17
AND #$80
BNE TESTA
STZ $0F63
TESTA:
LDA $0F63
BNE NotPressed
LDA $17 ;\
AND #$80 ;|If A is pressed go next time to MarioToSprite Routine
BEQ NotPressed ;|
;LDA $15A0,x ;|
;BNE OFFScreenPressed
;LDA $186C,x ;|
;BNE OFFScreenPressed
LDA #$02 ;|
STA $0F62 ;|
RTS ;|
OFFScreenPressed:
LDA #$2A
STA $1DFC
LDA $94 ;\
STA $E4,x ;|Sprite gets Mario position
LDA $95 ;|
STA $14E0,x ;|
LDA $96 ;|
STA $D8,x ;|
LDA $97 ;|
STA $14D4,x ;/
RTS
NotPressed: ;/
LDA $15 ;\
AND #$01 ;|Check if sprite should move
BNE RightA ;|
LDA $15 ;|
AND #$02 ;|
BNE LeftA ;|
LDA $15 ;|
AND #$04 ;|
BNE DownA ;|
LDA $15 ;|
AND #$08 ;|
BNE UpA ;/
JSR Graphics ;draw Graphics
RTS
RightA:
LDA #$10
STA $B6,x
JSL $018022
JSR Graphics ;draw Graphics
RTS
LeftA:
LDA #$F0
STA $B6,x
JSL $018022
JSR Graphics ;draw Graphics
RTS
DownA:
LDA #$10
STA $AA,x
JSL $01801A
JSR Graphics ;draw Graphics
RTS
UpA:
LDA #$F0
STA $AA,x
JSL $01801A
JSR Graphics ;draw Graphics
RTS
;=============================================================================
;Graphics
;=============================================================================
PROPERTIES: dcb $04,$06,$08,$0A
Graphics:
JSR GET_DRAW_INFO
LDA $00
STA $0300,y
LDA $01
CLC
ADC #$10
STA $0301,y
LDA $0303,y
ORA $64
STA $0303,y
LDA #$24
STA $0302,y
LDY #$02
LDA #$00
JSL $01B7B3
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine. It sets off screen flags, and sets up
; variables. It will return with the following:
;
; Y = index to sprite OAM ($300)
; $00 = sprite x position relative to screen boarder
; $01 = sprite y position relative to screen boarder
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPR_T1: dcb $0C,$1C
SPR_T2: dcb $01,$02
GET_DRAW_INFO: STZ $15A0,x ; reset sprite offscreen flag, vertical
STZ $186C,x ; reset sprite offscreen flag, horizontal
LDA $E4,x ; \
CMP $1A ; | set horizontal offscreen if necessary
LDA $14E0,x ; |
SBC $1B ; |
BEQ ON_SCREEN_X ; |
INC $186C,x ; /
ON_SCREEN_X: LDA $14E0,x ; \
XBA ; |
LDA $E4,x ; |
REP #$20 ; |
SEC ; |
SBC $1A ; | mark sprite invalid if far enough off screen
CLC ; |
ADC.W #$0040 ; |
CMP.W #$0180 ; |
SEP #$20 ; |
ROL A ; |
AND #$01 ; |
STA $15C4,x ; /
BNE INVALID ;
LDY #$00 ; \ set up loop:
LDA $1662,x ; |
AND #$20 ; | if not smushed (1662 & 0x20), go through loop twice
BEQ ON_SCREEN_LOOP ; | else, go through loop once
INY ; /
ON_SCREEN_LOOP: LDA $D8,x ; \
CLC ; | set vertical offscreen if necessary
ADC SPR_T1,y ; |
PHP ; |
CMP $1C ; | (vert screen boundry)
ROL $00 ; |
PLP ; |
LDA $14D4,x ; |
ADC #$00 ; |
LSR $00 ; |
SBC $1D ; |
BEQ ON_SCREEN_Y ; |
LDA $15A0,x ; | (vert offscreen)
ORA SPR_T2,y ; |
STA $15A0,x ; |
ON_SCREEN_Y: DEY ; |
BPL ON_SCREEN_LOOP ; /
LDY $15EA,x ; get offset to sprite OAM
LDA $E4,x ; \
SEC ; |
SBC $1A ; | $00 = sprite x position relative to screen boarder
STA $00 ; /
LDA $D8,x ; \
SEC ; |
SBC $1C ; | $01 = sprite y position relative to screen boarder
STA $01 ; /
RTS ; return
INVALID: PLA ; \ return from *main gfx routine* subroutine...
PLA ; | ...(not just this subroutine)
RTS ; /
wenn ich den code ausführe funktionirt grundsätzlich alles wie geplant...
aber wenn ich Marios position "Update":
Code
LDA $E4,x ;\
STA $94 ;| Mario gets Sprite position
LDA $14E0,x ;|
STA $95 ;|
LDA $D8,x ;|
STA $96 ;|
LDA $14D4,x ;|
STA $97 ;/
setzte ich ja einfach Marios X/Y position einfach wie ich sie gerne hätte aber wenn der screen nun scrollt kommt es zu dem problem das das spiel die falschen Blöcke lädt...
wie kann ich das verhindern?
WAS, WIE, WO???? Ne, Ne ich bin nicht die Signatur ...
Ich putze hier nur.
Mein Hack:
<!-- m --><a class="postlink" href="http://www.youtube.com/user/conankun88#p/a/u/0/8vdcyGylrg0">http://www.youtube.com/user/conankun88# ... vdcyGylrg0</a><!-- m -->
Ich putze hier nur.
Mein Hack:
<!-- m --><a class="postlink" href="http://www.youtube.com/user/conankun88#p/a/u/0/8vdcyGylrg0">http://www.youtube.com/user/conankun88# ... vdcyGylrg0</a><!-- m -->