Hey there!
I'm a noob in need of help.
Has anyone implemented a screen split with shiru's neslib?
I've tried to do one my self but without luck (either nothing happens, or the screen flickers between the two scrolls).
Any help would be appreciated!
So basically what I need is shiru's ppu_waitnmi() routine but with a sprite 0 hit check and scroll.
Here's shirus routines for ppu_waitnmi() and scroll(x, y):
and here are my messy attempts to combine whatever ppu_waitnmi() does with the sprite 0 check:
note that I was just trying random things at the end before I gave up = /
This is how I'd like my game loop to look like
Here's a screenshot, the orange square in the hud is my sprite 0
Note that my assembly knowledge is extremely low (first time working with it last night).
Thanks in beforehand,
Mattias.
I'm a noob in need of help.
Has anyone implemented a screen split with shiru's neslib?
I've tried to do one my self but without luck (either nothing happens, or the screen flickers between the two scrolls).
Any help would be appreciated!
So basically what I need is shiru's ppu_waitnmi() routine but with a sprite 0 hit check and scroll.
Here's shirus routines for ppu_waitnmi() and scroll(x, y):
Code:
_ppu_waitnmi:
lda #1
sta <VRAMUPDATE
lda <FRAMECNT1
@1:
cmp <FRAMECNT1
beq @1
lda <NTSCMODE
beq @3
@2:
lda <FRAMECNT2
cmp #5
beq @2
@3:
lda #0
sta <VRAMUPDATE
rts
_scroll:
sta <TEMP
txa
bne @1
lda <TEMP
cmp #240
bcs @1
sta <SCROLL_Y
lda #0
sta <TEMP
beq @2 ;bra
@1:
sec
lda <TEMP
sbc #240
sta <SCROLL_Y
lda #2
sta <TEMP
@2:
jsr popax
sta <SCROLL_X
txa
and #$01
ora <TEMP
sta <TEMP
lda <PPU_CTRL_VAR
and #$fc
ora <TEMP
sta <PPU_CTRL_VAR
rts
lda #1
sta <VRAMUPDATE
lda <FRAMECNT1
@1:
cmp <FRAMECNT1
beq @1
lda <NTSCMODE
beq @3
@2:
lda <FRAMECNT2
cmp #5
beq @2
@3:
lda #0
sta <VRAMUPDATE
rts
_scroll:
sta <TEMP
txa
bne @1
lda <TEMP
cmp #240
bcs @1
sta <SCROLL_Y
lda #0
sta <TEMP
beq @2 ;bra
@1:
sec
lda <TEMP
sbc #240
sta <SCROLL_Y
lda #2
sta <TEMP
@2:
jsr popax
sta <SCROLL_X
txa
and #$01
ora <TEMP
sta <TEMP
lda <PPU_CTRL_VAR
and #$fc
ora <TEMP
sta <PPU_CTRL_VAR
rts
and here are my messy attempts to combine whatever ppu_waitnmi() does with the sprite 0 check:
note that I was just trying random things at the end before I gave up = /
Code:
;void __fastcall__ waitSprite0rel(void);
_waitSprite0rel:
lda #1 ;no idéa what these two lines do, took it from ppu_waitnmi()
sta <VRAMUPDATE ;but I think the sprites didn't even show up if I didn't include them = /
lda $2002
and #$40
beq _waitSprite0rel
rts
;void __fastcall__ waitSprite0set(void);
_waitSprite0set:
lda $2002
and #$40
bne _waitSprite0set
; lda $2000
; and #$FE
; sta $2000
lda #0 ;same as above, these two are from ppu_waitnmi()
sta <VRAMUPDATE
rts
;void __fastcall__ waitVBLANKrel(void);
_waitVBLANKrel:
lda <FRAMECNT1
_waitVBLANKloop:
cmp <FRAMECNT1
beq _waitVBLANKloop
lda #0 ;same as above, these two are from ppu_waitnmi()
sta <VRAMUPDATE
rts
_waitSprite0rel:
lda #1 ;no idéa what these two lines do, took it from ppu_waitnmi()
sta <VRAMUPDATE ;but I think the sprites didn't even show up if I didn't include them = /
lda $2002
and #$40
beq _waitSprite0rel
rts
;void __fastcall__ waitSprite0set(void);
_waitSprite0set:
lda $2002
and #$40
bne _waitSprite0set
; lda $2000
; and #$FE
; sta $2000
lda #0 ;same as above, these two are from ppu_waitnmi()
sta <VRAMUPDATE
rts
;void __fastcall__ waitVBLANKrel(void);
_waitVBLANKrel:
lda <FRAMECNT1
_waitVBLANKloop:
cmp <FRAMECNT1
beq _waitVBLANKloop
lda #0 ;same as above, these two are from ppu_waitnmi()
sta <VRAMUPDATE
rts
This is how I'd like my game loop to look like
Code:
updateEverything();
scroll(0, scrollY);
waitSprite0rel(); // waits until rendering starts?
waitSprite0set(); // waits for sprite 0 hit?
scroll(scrollX, scrollY); // scrolls screen directly after hit
waitVBLANKrel(); // waits for rendering to end!?
scroll(0, scrollY);
waitSprite0rel(); // waits until rendering starts?
waitSprite0set(); // waits for sprite 0 hit?
scroll(scrollX, scrollY); // scrolls screen directly after hit
waitVBLANKrel(); // waits for rendering to end!?
Here's a screenshot, the orange square in the hud is my sprite 0
Note that my assembly knowledge is extremely low (first time working with it last night).
Thanks in beforehand,
Mattias.