CPCWiki forum

General Category => Programming => Topic started by: funkheld on 09:36, 15 July 20

Title: poke for sdcc poke(int a, char b) ?
Post by: funkheld on 09:36, 15 July 20

Hi good afternoon.
I found this spoke.
how can you make poke (a, b) of it
a = 0xc000 and b = 129.

then how does a peek please?

it is sdcc.

thank you.
greeting

H

it is
thank you.
greeting

void poke(int a) {
__asm
  ld h,5(ix)
  ld l,4(ix)
  ld (hl),#129
__endasm;


}


void main() {
   int addr;
  char s;
   for (addr=0xc000;addr<0xffff;addr++) {
    s= 128;
      poke(addr);
   }
}
Title: Re: poke for sdcc poke(int a, char b) ?
Post by: pelrun on 09:48, 15 July 20
The same way you write to any address in C, via pointers.
unsigned char *ptr;

ptr = 0xc000;
*ptr = 129;
printf("read from 0xc000: %d", *ptr);
Title: Re: poke for sdcc poke(int a, char b) ?
Post by: Sykobee (Briggsy) on 10:01, 15 July 20
It looks like a screen clear routine - I'd put a screen clear routine entirely in ASM (e.g., using the stack clear method - Save SP, Change SP to FFFF, PUSH * 16K of the value you want, restore SP).


But in plain C just use pointers as pelrun says - but that won't compile to the fastest screen clear code.
Title: Re: poke for sdcc poke(int a, char b) ?
Post by: funkheld on 10:39, 15 July 20
hello, thanks for info.


greetring
Powered by SMFPacks Menu Editor Mod