fixed scanline bug + removed old code
This commit is contained in:
parent
9f2ddc6621
commit
c4ccba52d2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
build
|
||||
*.swp
|
||||
*.swo
|
||||
|
@ -7,7 +7,6 @@ SECTION "Actor", ROM0
|
||||
ActorROM::
|
||||
.structs:
|
||||
dw ActorIdle
|
||||
.tiles:
|
||||
ActorIdle::
|
||||
db 60
|
||||
db 15
|
||||
|
@ -15,20 +15,20 @@ SECTION "Actor STructs", WRAM0
|
||||
|
||||
dstruct Actor, Player
|
||||
|
||||
SECTION "Animation Variables", WRAM0
|
||||
SECTION "Animation Variables", HRAM
|
||||
|
||||
wCameraX: dw
|
||||
wCameraY: dw
|
||||
hCameraX: dw
|
||||
hCameraY: dw
|
||||
|
||||
wWorkingX: dw
|
||||
wWorkingY: dw
|
||||
wWorkingScreenX: db
|
||||
wWorkingScreenY: db
|
||||
wWorkingState: db
|
||||
wWorkingCounter: db
|
||||
wWorkingData: dw
|
||||
wWorkingTile: db
|
||||
wWorkingEnd:
|
||||
hWorkingX: dw
|
||||
hWorkingY: dw
|
||||
hWorkingScreenX: db
|
||||
hWorkingScreenY: db
|
||||
hWorkingState: db
|
||||
hWorkingCounter: db
|
||||
hWorkingData: dw
|
||||
hWorkingTile: db
|
||||
hWorkingEnd:
|
||||
|
||||
SECTION "Animations Subs", ROM0
|
||||
|
||||
@ -48,27 +48,27 @@ RenderActor::
|
||||
; @input: hl <- Player
|
||||
; @input: de <- ShadowOAM place
|
||||
ld a, [hli] ; a <- YPos
|
||||
ld [wWorkingScreenY], a
|
||||
ldh [hWorkingScreenY], a
|
||||
ld a, [hli] ; a <- XPos
|
||||
ld [wWorkingScreenX], a
|
||||
ldh [hWorkingScreenX], a
|
||||
push hl
|
||||
ld a, [hli] ; a <- GFXCounter
|
||||
ld [wWorkingCounter], a
|
||||
ldh [hWorkingCounter], a
|
||||
ld a, [hli] ; a <- GFXState
|
||||
ld [wWorkingState], a
|
||||
ldh [hWorkingState], a
|
||||
ld a, [hli] ; a <- GFXData(Low)
|
||||
ld [wWorkingData+1], a
|
||||
ldh [hWorkingData+1], a
|
||||
ld a, [hli] ; a <- GFXData (High)
|
||||
ld [wWorkingData], a
|
||||
ldh [hWorkingData], a
|
||||
ld a, [hl] ; a <- TileData
|
||||
ld [wWorkingTile], a
|
||||
ldh [hWorkingTile], a
|
||||
; fin loading data
|
||||
ld a, [wWorkingData]
|
||||
ld a, [hWorkingData]
|
||||
ld l, a
|
||||
ld a, [wWorkingData+1]
|
||||
ld a, [hWorkingData+1]
|
||||
ld h, a
|
||||
; add actor struct offset saved in wWorkingState
|
||||
ld a, [wWorkingState]
|
||||
ld a, [hWorkingState]
|
||||
rlca ; double state offset because of word length
|
||||
add a, l
|
||||
ld l, a
|
||||
@ -82,7 +82,7 @@ RenderActor::
|
||||
ld h, a
|
||||
ld a, [hli] ; a <- state frame limit
|
||||
ld b, a
|
||||
ld a, [wWorkingCounter]
|
||||
ld a, [hWorkingCounter]
|
||||
inc a
|
||||
ld c, a
|
||||
ld a, b
|
||||
@ -93,7 +93,7 @@ RenderActor::
|
||||
xor a
|
||||
.continueAnimation
|
||||
; TODO: make counter 0 indexed so doesnt skip first frame
|
||||
ld [wWorkingCounter], a
|
||||
ldh [hWorkingCounter], a
|
||||
ld b, h
|
||||
ld c, l
|
||||
pop hl
|
||||
@ -124,7 +124,7 @@ RenderActor::
|
||||
; load Y position, then offset by -16
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld a, [wWorkingScreenY]
|
||||
ld a, [hWorkingScreenY]
|
||||
add c
|
||||
ld c, 16
|
||||
add c
|
||||
@ -133,7 +133,7 @@ RenderActor::
|
||||
; load X position, then offset by -8
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld a, [wWorkingScreenX]
|
||||
ld a, [hWorkingScreenX]
|
||||
add c
|
||||
ld c, 8
|
||||
add c
|
||||
@ -142,7 +142,7 @@ RenderActor::
|
||||
; load tile offset, and add to base tile pointer
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld a, [wWorkingTile]
|
||||
ld a, [hWorkingTile]
|
||||
add c
|
||||
ld [de], a
|
||||
inc de
|
||||
|
@ -12,19 +12,8 @@ P1F_DPAD EQU $20
|
||||
|
||||
SECTION "ROM Vars", ROM0
|
||||
|
||||
dPlayerWidth: db 2
|
||||
dPlayerHeight: db 2
|
||||
dPlayerSpriteTiles: db $01, $02, $09, $0A
|
||||
|
||||
SECTION "WRAM Vars", WRAM0[$C000]
|
||||
|
||||
X: dw
|
||||
N: dw
|
||||
ANS: db
|
||||
|
||||
rPlayerX: db
|
||||
rPlayerY: db
|
||||
|
||||
SECTION "HRAM Vars", HRAM
|
||||
|
||||
hVBlankFlag: db
|
||||
|
@ -25,8 +25,6 @@ Start:
|
||||
ld [rSCY], a
|
||||
ld [rSCX], a
|
||||
ld [rNR52], a
|
||||
ld a, LCDCF_ON | LCDCF_OBJON | LCDCF_BGON
|
||||
ld [rLCDC], a
|
||||
|
||||
call CopyDMARoutine
|
||||
|
||||
@ -43,11 +41,14 @@ Start:
|
||||
ld a, LOW(ActorROM)
|
||||
ld [Player_GFXData + 1], a
|
||||
|
||||
ld a, LCDCF_ON | LCDCF_OBJON | LCDCF_BGON
|
||||
ld [rLCDC], a
|
||||
|
||||
game_loop:
|
||||
call Wait_VBlank
|
||||
call Hide_OAM
|
||||
call Read_Pad
|
||||
call PC_Update
|
||||
call Clear_OAM
|
||||
call Wait_VBlank
|
||||
ld de, wShadowOAM
|
||||
ld hl, Player
|
||||
call RenderActor
|
||||
|
113
src/misc.asm
113
src/misc.asm
@ -1,102 +1,3 @@
|
||||
Player_To_OAM:
|
||||
; -- first loop --
|
||||
ld hl, wShadowOAM
|
||||
ld a, [dPlayerHeight]
|
||||
ld b, a
|
||||
ld d, 16
|
||||
ld a, [rPlayerY]
|
||||
add d ; d has the base Y value (counting offsets)
|
||||
ld d, a
|
||||
.fouter
|
||||
ld a, [dPlayerWidth]
|
||||
ld c, a ; c is finner counter
|
||||
.finner
|
||||
ld a, d
|
||||
ld [hl], a
|
||||
ld a, 4
|
||||
call .add4hl
|
||||
; end of finner loop
|
||||
dec c
|
||||
jr nz, .finner
|
||||
ld a, d
|
||||
ld d, 8
|
||||
add d
|
||||
ld d, a
|
||||
; end of fouter loop
|
||||
dec b
|
||||
jr nz, .fouter
|
||||
; -- second loop --
|
||||
ld hl, wShadowOAM+1
|
||||
ld a, [dPlayerHeight]
|
||||
ld b, a
|
||||
.souter
|
||||
ld d, 8
|
||||
ld a, [rPlayerX]
|
||||
add d
|
||||
ld d, a
|
||||
ld a, [dPlayerWidth]
|
||||
ld c, a
|
||||
.sinner
|
||||
ld a, d
|
||||
ld [hl], a
|
||||
add 8
|
||||
ld d, a
|
||||
ld a, 4
|
||||
call .add4hl
|
||||
dec c
|
||||
jr nz, .sinner
|
||||
dec b
|
||||
jr nz, .souter
|
||||
; -- third loop --
|
||||
ld hl, wShadowOAM+2
|
||||
ld de, dPlayerSpriteTiles
|
||||
ld a, [dPlayerHeight]
|
||||
ld b, a
|
||||
ld a, [dPlayerWidth]
|
||||
ld c, a
|
||||
xor a
|
||||
.tloop1
|
||||
add b
|
||||
dec c
|
||||
jr nz, .tloop1
|
||||
ld c, a
|
||||
.tloop2
|
||||
ld a, [de]
|
||||
ld [hl], a
|
||||
ld a, 4
|
||||
call .add4hl
|
||||
inc de
|
||||
dec c
|
||||
jr nz, .tloop2
|
||||
; -- fourth loop --
|
||||
ld hl, wShadowOAM+3
|
||||
ld a, [dPlayerHeight]
|
||||
ld b, a
|
||||
ld a, [dPlayerWidth]
|
||||
ld c, a
|
||||
xor a
|
||||
.lloop1
|
||||
add b
|
||||
dec c
|
||||
jr nz, .lloop1
|
||||
ld c, a
|
||||
.lloop2
|
||||
xor a
|
||||
ld [hl], a
|
||||
ld a, 4
|
||||
call .add4hl
|
||||
dec c
|
||||
jr nz, .lloop2
|
||||
ret
|
||||
|
||||
.add4hl:
|
||||
add a, l ; a = low + old_l
|
||||
ld l, a ; a = low + old_l = new_l
|
||||
adc a, h ; a = new_l + old_h + carry
|
||||
sub l ; a = old_h + carry
|
||||
ld h, a
|
||||
ret
|
||||
|
||||
PC_Update:
|
||||
ld b, 0
|
||||
ld c, 0
|
||||
@ -146,6 +47,20 @@ Clear_OAM:
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
Hide_OAM:
|
||||
ld hl, wShadowOAM
|
||||
ld c, wShadowOAMEnd - wShadowOAM
|
||||
.loop:
|
||||
xor a
|
||||
ld [hl], a
|
||||
ld a, l
|
||||
or 3
|
||||
inc a
|
||||
ld l, a
|
||||
dec c
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
Clear_Map:
|
||||
ld hl, _SCRN0
|
||||
ld bc, _SCRN0_END - _SCRN0
|
||||
|
Loading…
Reference in New Issue
Block a user