Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2020-05-16 11:57:38

h0tp3ngu1n
Member
Registered: 2019-08-18
Posts: 25

ASM - Vertical screen stretching effect?

I'm trying to do some sort of screen effect, where the lower half of the screen should be stretched vertically by 200%.

I'm still kind of new so I really don't know if this is even how you'd go about doing it, but here's what I've tried: (this is the main game loop)

Code:

        ; Wait for LCDC to be in mode 0 (hblank)
.get_into_mode_0:
    ld a,[rSTAT]
    and a,%00000011
    cp a,0
    jr nz,.get_into_mode_0

        ; Check whether the current scanline is greater than 72
    ld a,[rLY]
    cp a,72
    jr nc,.get_out_of_mode_0

        ; If it is, check whether the current scanline is even or odd
    and a,%1
    cp a,1
    jr z,.get_out_of_mode_0

        ; If even, scroll by 1 (should stretch that row vertically 200%)
    ld a,[rSCY]
    inc a
    ld [rSCY],a

        ; Wait for LCDC to exit mode 0
.get_out_of_mode_0:
    ld a,[rSTAT]
    and a,%00000011
    cp a,0
    jr z,.get_out_of_mode_0

    jr .get_into_mode_0

Needless to say, the code doesn't do what I want it to. Anyone have any ideas?

Last edited by h0tp3ngu1n (2020-05-16 11:58:05)

Offline

 

#2 2020-05-17 06:49:11

Tauwasser
Member
Registered: 2010-10-23
Posts: 160

Re: ASM - Vertical screen stretching effect?

You would need to use the LCDC Status interrupt, because you would want to change the Y scroll register every line (reset to default on even lines, reset to last even line on odd lines). Code running in your mainloop is going to be much too slow for this, as you would never realiably catch all lines.
Most games have an optional "special effects mode" that is checked on every LCDC Status interrupt (if enabled). That way you can turn your stretch mode on and off easily.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson