Join us on Discord!
You can help CodeWalrus stay online by donating here.
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Midnightas

#1
General Help & Troubleshooting / What causes "RAM leaks"?
February 05, 2019, 04:54:16 PM
I am writing a simple game in ez80 assembly, and every single time I run the program, my calculator's free RAM goes down a lot.
I can run the game maybe 4-5 times before it runs out and a memory error occurs.

Is my program simply not deallocated from memory, if so, how do I get it to?
#2
I added double buffering into my program, as before you could see it rendering visually and flickering.
But now with double buffering, half of the screen flickers (not exactly half, I can't find a pattern, but it's mostly pixels at the bottom), and it now takes around half a second to render, before the buffers are swapped again.
I'm assuming this is because we wait for the interrupt, but it still seems to be very long.

call SJQ_setgraphics
loop:
; Simple buffer cleaning, sets everything to 0.
ld HL, (SJQ_curbuf)
ld (HL), 0
ld DE, (SJQ_curbuf)
inc DE
ld BC, 320 * 240 - 1
ldir

; do some more drawing here.

call SJQ_bufswap

SJQ_setgraphics:
; Sets the palette.
ld HL, SJQ_PALETTE
ld DE, $E30200
ld BC, SJQ_PALETTE_END - SJQ_PALETTE
ldir
; Enables 8bpp.
ld A, $27
ld ($E30018), A
; Sets up double buffering.
ld HL, vRam
ld (mpLcdBase), HL
ld hl, vRam + 320 * 240
ld (SJQ_curbuf), HL
ld HL, mpLcdImsc
ld (HL), 4
ret

SJQ_bufswap:
ld HL, (SJQ_curbuf)
ld DE, (mpLcdBase)
ld (SJQ_curbuf), DE
ld (mpLcdBase), HL
_:
ld HL, mpLcdIcr
set 2, (HL)
ld HL, mpLcdRis
_:
bit 2, (HL)
jr Z, -_
ret


SJQ_bufwap, the third third of SJQ_setgraphics are all that work on the double buffering, of course I found little docs on the internet (searching stuff like 'double buffering ti', or using exact matching, etc).
Powered by EzPortal