I found a couple of functions by MateoConLechuga here and copy pasted them into my program, but it seems to make the entire screen look like a grid of different colors. I can't post a screenshot as it seems to show everything as if it was fine.

Here's the source:

Code:
SJQ_gameloop:
   ld HL, SJQ_current_buffer
   ld DE, %1111100011100011
   ld BC, 320 * 240
   call SJQ_MemSet16
   
   call SJQ_bufswap
   
   call _GetCSC
   cp A, skEnter
   jp NZ, SJQ_gameloop
SJQ_gameend:
   call _homeup
   call _ClrScrnFull
   ret

SJQ_bufsetup:
   ld HL, SJQ_current_buffer
   ld DE, vRam + 320 * 240
   ld (HL), DE
   ld L, mpLcdIcr & $FF
   ld (HL), 4
   ret
SJQ_bufswap:
   ld HL, vRam
   ld DE, (mpLcdBase)
   or A, A
   sbc HL,DE
   add HL,DE
   jr NZ, +_
   ld HL, vRam + 320 * 240
_:   
   ld (SJQ_current_buffer), DE
   ld (mpLcdBase), HL
   ld HL, mpLcdIcr
   set 2, (HL)
   ld L, mpLcdRis & $FF
_:   
   bit 2, (HL)
   jr Z, -_
   ret

SJQ_current_buffer equ 0e30014h

As you can see, all I'm trying to do is make the screen a bit red+green. Or am I stupid and double-buffering isn't supported on 16bpp?
vRam contains exactly enough memory for a single 16bpp screen buffer that is used by TIOS. Double buffering relies on switching to 8bpp so that each pixel takes up half the space leaving you with enough room for both buffers.
Thanks, but then I have another question: how to make SJQ_SetMem16 a bit faster?
You can see how it's setting the values slowly one by one on the screen.

The function's supposed to be like a regular C memset except it sets 2-byte values, but right now it does it the slow looping way with cpi.
Untested:
Code:
void *memset2(void *s, int c, size_t n);

Code:
_memset2:
   pop   iy
   pop   hl
   pop   de
   pop   bc
   push   bc
   push   de
   push   hl
   push   iy
   cpi
   add   hl,bc
   ret   c
   add   hl,bc
   ld   (hl),d
   dec   hl
   ld   (hl),e
   ret   po
   push   hl
   pop   de
   inc   hl
   dec   de
   push   bc
   lddr
   pop   bc
   lddr
   ret
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement